Skip to content

Commit

Permalink
Fix down migration 16.
Browse files Browse the repository at this point in the history
  • Loading branch information
piohei committed Dec 3, 2024
1 parent 7ff3ac0 commit c61cf13
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions schemas/database/016_remove_recovery.down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ CREATE TABLE recoveries (
new_commitment BYTEA NOT NULL UNIQUE
);

-- It may look strange but this way we restore the order of columns. The order is important
-- as we use 'SELECT * FROM' in application code and then get data based on that order.
ALTER TABLE unprocessed_identities
RENAME COLUMN created_at TO created_at_old;

ALTER TABLE unprocessed_identities
ADD COLUMN eligibility TIMESTAMPTZ,
ADD COLUMN status VARCHAR(50),
ADD COLUMN created_at TIMESTAMPTZ,
ADD COLUMN processed_at TIMESTAMPTZ,
ADD COLUMN error_message TEXT;
ADD COLUMN error_message TEXT,
ADD COLUMN eligibility TIMESTAMPTZ;

UPDATE unprocessed_identities SET created_at = created_at_old;
UPDATE unprocessed_identities SET status = 'new', eligibility = CURRENT_TIMESTAMP WHERE status IS NULL;

ALTER TABLE unprocessed_identities
ALTER COLUMN created_at SET NOT NULL;
ALTER TABLE unprocessed_identities
ALTER COLUMN status SET NOT NULL;
ALTER TABLE unprocessed_identities
DROP COLUMN created_at_old;

0 comments on commit c61cf13

Please sign in to comment.