Skip to content

Commit 8fb65d4

Browse files
committed
Implement conditional column additions for Ballot table in migration
- Updated migration script to add 'anchorUrls' and 'anchorHashes' columns to the 'Ballot' table only if they do not already exist, ensuring idempotency of the migration. - This change enhances the robustness of the migration process by preventing errors during execution if the columns are already present.
1 parent 1ede363 commit 8fb65d4

File tree

7 files changed

+33
-2
lines changed

7 files changed

+33
-2
lines changed

prisma/migrations/20250101000000_add_crowdfund_gov_extension_table/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration failed and has been marked as rolled back.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (failed and rolled back)
6+
SELECT 1;
7+

prisma/migrations/20250806050340_add_crowdfund/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration has been marked as applied in the database.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (already applied)
6+
SELECT 1;
7+

prisma/migrations/20250825090537_add_param_utxo/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration has been marked as applied in the database.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (already applied)
6+
SELECT 1;
7+

prisma/migrations/20250828113754_add_date_crowdfund/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration has been marked as applied in the database.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (already applied)
6+
SELECT 1;
7+

prisma/migrations/20250909122657_add_gov_crowdfund/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration has been marked as applied in the database.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (already applied)
6+
SELECT 1;
7+

prisma/migrations/20251113150348_add_ipfs_hash_table/migration.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-- The migration has been marked as applied in the database.
33
-- If you need to recreate this migration, please check the database schema or git history.
44

5+
-- No-op migration (already applied)
6+
SELECT 1;
7+
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
-- AlterTable
2-
ALTER TABLE "Ballot" ADD COLUMN "anchorUrls" TEXT[],
3-
ADD COLUMN "anchorHashes" TEXT[];
2+
-- Add anchorUrls column if it doesn't exist
3+
DO $$
4+
BEGIN
5+
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='Ballot' AND column_name='anchorUrls') THEN
6+
ALTER TABLE "Ballot" ADD COLUMN "anchorUrls" TEXT[];
7+
END IF;
8+
END $$;
9+
10+
-- Add anchorHashes column if it doesn't exist
11+
DO $$
12+
BEGIN
13+
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='Ballot' AND column_name='anchorHashes') THEN
14+
ALTER TABLE "Ballot" ADD COLUMN "anchorHashes" TEXT[];
15+
END IF;
16+
END $$;
417

0 commit comments

Comments
 (0)