Skip to content

Commit 8665e19

Browse files
graylikemeclaude
andcommitted
fix: drop/re-add ammo_for_id FK in seed/load.sh
The equipment table has a circular FK (ammo_for_id → equipment.id) which causes insert failures when loading a pg_dump with --inserts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent baf6d14 commit 8665e19

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

seed/load.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ else
3232
exit 1
3333
fi
3434

35+
echo "==> Dropping circular FK (equipment.ammo_for_id)..."
36+
psql "$DB_URL" -q -c "ALTER TABLE equipment DROP CONSTRAINT IF EXISTS equipment_ammo_for_id_fkey;"
37+
3538
echo "==> Truncating tables..."
3639
psql "$DB_URL" -q -c "
3740
TRUNCATE
@@ -71,6 +74,9 @@ psql "$DB_URL" -q -c "
7174
echo "==> Loading seed data..."
7275
gunzip -c "$DUMP_FILE" | psql "$DB_URL" -q -o /dev/null
7376

77+
echo "==> Re-adding circular FK..."
78+
psql "$DB_URL" -q -c "ALTER TABLE equipment ADD CONSTRAINT equipment_ammo_for_id_fkey FOREIGN KEY (ammo_for_id) REFERENCES equipment(id) ON DELETE SET NULL;"
79+
7480
echo "==> Resetting sequences..."
7581
psql "$DB_URL" -q -o /dev/null -c "
7682
SELECT setval('dataset_metadata_id_seq', COALESCE((SELECT MAX(id) FROM dataset_metadata), 0) + 1, false);

0 commit comments

Comments
 (0)