fix: migration

This commit is contained in:
efrilm
2026-10-12 22:07:22 +07:00
parent 3af16a1fbc
commit 0f60aadbfd
@@ -2,6 +2,21 @@
-- which budget (docs/rfc-enakgame.md §5.7, D5). Replaces the unused rewards table for -- which budget (docs/rfc-enakgame.md §5.7, D5). Replaces the unused rewards table for
-- EnakGame; rewards itself stays. -- 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 ( CREATE TABLE vouchers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
organization_id UUID NOT NULL, organization_id UUID NOT NULL,