fix: migration
This commit is contained in:
@@ -2,6 +2,21 @@
|
||||
-- which budget (docs/rfc-enakgame.md §5.7, D5). Replaces the unused rewards table for
|
||||
-- EnakGame; rewards itself stays.
|
||||
|
||||
-- Some databases still have the vouchers table of the reverted Voucher Undian feature
|
||||
-- (commit cfe690a). Keep its data under another name; its primary key index is renamed
|
||||
-- too, or vouchers_pkey below would clash.
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = current_schema() AND table_name = 'vouchers' AND column_name = 'winner_number'
|
||||
) THEN
|
||||
ALTER TABLE vouchers RENAME TO vouchers_undian_legacy;
|
||||
ALTER INDEX IF EXISTS vouchers_pkey RENAME TO vouchers_undian_legacy_pkey;
|
||||
ALTER INDEX IF EXISTS vouchers_voucher_code_key RENAME TO vouchers_undian_legacy_voucher_code_key;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE TABLE vouchers (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
organization_id UUID NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user