Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

announcements: add start at edition date #2575

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions workspaces/announcements/.changeset/flat-numbers-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@backstage-community/plugin-announcements-backend': minor
'@backstage-community/plugin-announcements-common': minor
'@backstage-community/plugin-announcements-react': minor
'@backstage-community/plugin-announcements': minor
---

- Added a `start_at` field to allow users to set the date when an announcement occurred.
- Announcements can now be sorted by `created_at` (default) or `start_at`, with customizable order (desc or asc).
- Updated the New Announcement form to accommodate start_at and future fields.
- Added `created_at` and `start_at` columns to the admin view table.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = async function up(knex) {
// Add the new column as nullable initially
await knex.schema.alterTable('announcements', table => {
table.timestamp('start_at').nullable();
});

// Backfill the start_at column with values from created_at
await knex('announcements').update({
start_at: knex.raw('created_at'),
});

// Alter the column to be not nullable
await knex.schema.alterTable('announcements', table => {
table.timestamp('start_at').notNullable().alter();
});
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = async function down(knex) {
await knex.schema.alterTable('announcements', table => {
table.dropColumn('start_at');
});
};
Loading
Loading