-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add support for ad-hoc schedule entries 🕒 (#154)
Made work_item_id nullable in the database schema Added ad_hoc as a valid work_item_type Updated UI components to handle ad-hoc entries Enhanced validation logic for ad-hoc entries Improved logging and error handling "Curiouser and curiouser! 🐇 Now you can schedule ad-hoc entries, just like the White Rabbit's ever-changing appointments. Time is a funny thing, isn't it? ⏳"
- Loading branch information
1 parent
ea65a6c
commit 2d38da0
Showing
11 changed files
with
344 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
server/migrations/20250103172553_add_adhoc_schedule_entries.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Add support for ad-hoc schedule entries | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = async function(knex) { | ||
// First, make work_item_id nullable | ||
await knex.schema.alterTable('schedule_entries', table => { | ||
table.uuid('work_item_id').alter().nullable(); | ||
}); | ||
|
||
// Then update the work_item_type check constraint | ||
await knex.raw(` | ||
ALTER TABLE schedule_entries | ||
DROP CONSTRAINT IF EXISTS schedule_entries_work_item_type_check; | ||
`); | ||
|
||
await knex.raw(` | ||
ALTER TABLE schedule_entries | ||
ADD CONSTRAINT schedule_entries_work_item_type_check | ||
CHECK (work_item_type = ANY (ARRAY['project_task'::text, 'ticket'::text, 'ad_hoc'::text])); | ||
`); | ||
}; | ||
|
||
/** | ||
* Revert support for ad-hoc schedule entries | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = async function(knex) { | ||
// First, ensure no ad-hoc entries exist | ||
await knex('schedule_entries') | ||
.where({ work_item_type: 'ad_hoc' }) | ||
.delete(); | ||
|
||
// Then make work_item_id required again | ||
await knex.schema.alterTable('schedule_entries', table => { | ||
table.uuid('work_item_id').alter().notNullable(); | ||
}); | ||
|
||
// Finally, restore the original work_item_type check constraint | ||
await knex.raw(` | ||
ALTER TABLE schedule_entries | ||
DROP CONSTRAINT IF EXISTS schedule_entries_work_item_type_check; | ||
`); | ||
|
||
await knex.raw(` | ||
ALTER TABLE schedule_entries | ||
ADD CONSTRAINT schedule_entries_work_item_type_check | ||
CHECK (work_item_type = ANY (ARRAY['project_task'::text, 'ticket'::text])); | ||
`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.