init push
This commit is contained in:
33
migrations/20260609_fix_duty_roster_crews_fk.sql
Normal file
33
migrations/20260609_fix_duty_roster_crews_fk.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- +goose Up
|
||||
-- Rewire crew FK to point at duty_rosters.
|
||||
|
||||
ALTER TABLE duty_roster_crews
|
||||
DROP FOREIGN KEY fk_hems_duty_rosters_crews,
|
||||
ADD CONSTRAINT fk_duty_roster_crews_roster
|
||||
FOREIGN KEY (roster_id) REFERENCES duty_rosters(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE duty_roster_other_persons
|
||||
DROP FOREIGN KEY fk_duty_roster_other_persons_roster,
|
||||
ADD CONSTRAINT fk_duty_roster_other_persons_roster
|
||||
FOREIGN KEY (roster_id) REFERENCES duty_rosters(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
-- +goose Down
|
||||
-- Restore crew FK back to the legacy table.
|
||||
|
||||
ALTER TABLE duty_roster_crews
|
||||
DROP FOREIGN KEY fk_duty_roster_crews_roster,
|
||||
ADD CONSTRAINT fk_hems_duty_rosters_crews
|
||||
FOREIGN KEY (roster_id) REFERENCES hems_duty_rosters(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE duty_roster_other_persons
|
||||
DROP FOREIGN KEY fk_duty_roster_other_persons_roster,
|
||||
ADD CONSTRAINT fk_duty_roster_other_persons_roster
|
||||
FOREIGN KEY (roster_id) REFERENCES hems_duty_rosters(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user