Skip to content

Commit

Permalink
For real fix the migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Dec 31, 2023
1 parent 0eb7dc3 commit 21874c9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions apps/server/migrations/0074_amused_purple_man.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
INSERT INTO bottle_alias
SELECT DISTINCT bottle_id, name
INSERT INTO bottle_alias (name, bottle_id)
SELECT DISTINCT ON (name) name, bottle_id
FROM store_price
ON CONFLICT (name) DO UPDATE
SET bottle_id = bottle_alias.bottle_id
WHERE bottle_alias.bottle_id IS NULL;

UPDATE store_price SET bottle_id = (SELECT bottle_id FROM bottle_alias WHERE name = store_price.name) WHERE bottle_id IS NULL;

INSERT INTO bottle_alias
SELECT DISTINCT bottle_id, name
INSERT INTO bottle_alias (name, bottle_id)
SELECT DISTINCT ON (name) name, bottle_id
FROM review
ON CONFLICT (name) DO UPDATE
SET bottle_id = bottle_alias.bottle_id
WHERE bottle_alias.bottle_id IS NULL;

UPDATE review SET bottle_id = (SELECT bottle_id FROM bottle_alias WHERE name = review.name) WHERE bottle_id IS NULL;


UPDATE bottle_alias
SET bottle_id = (
SELECT id FROM bottles WHERE full_name = bottle_alias.name
)
WHERE bottle_id IS NULL;

0 comments on commit 21874c9

Please sign in to comment.