-
-
Save DonerKebab/8c8d71970d84229ba561923ec21a6390 to your computer and use it in GitHub Desktop.
### _ListingToSpelling | |
ALTER TABLE "Item" | |
ADD CONSTRAINT "Item_id_unique" UNIQUE (id); | |
ALTER TABLE "_ListingToSpelling" | |
ADD COLUMN "itemId" text SET NOT NULL; | |
UPDATE "_ListingToSpelling" ls | |
SET "itemId" = CAST(i.id as uuid) | |
FROM "Item" i | |
WHERE ls."A" = i.url; | |
ALTER TABLE "_ItemToLocalOptionGroup" | |
ALTER COLUMN "itemId" SET NOT NULL; ALTER COLUMN "itemId" SET NOT NULL | |
ALTER TABLE "_ListingToSpelling" | |
DROP CONSTRAINT "_ListingToSpelling_A_fkey"; | |
ALTER TABLE "_ListingToSpelling" | |
ADD CONSTRAINT "_ListingToSpelling_itemId_fkey" | |
FOREIGN KEY ("itemId") REFERENCES "Item"(id) ON UPDATE CASCADE ON DELETE CASCADE; | |
ALTER TABLE "_ListingToSpelling" | |
ADD CONSTRAINT "_ListingToSpelling_B_itemId_unique" UNIQUE ("B", "itemId"); | |
ALTER TABLE "_ListingToSpelling" | |
DROP COLUMN "A"; | |
### _ListingToSpelling |
_GlobalOptionGroupToItem
ALTER TABLE "_GlobalOptionGroupToItem"
ADD COLUMN "itemId" text;
UPDATE "_GlobalOptionGroupToItem" ls
SET "itemId" = CAST(i.id as uuid)
FROM "Item" i
WHERE ls."B" = i.url;
ALTER TABLE "_GlobalOptionGroupToItem"
ALTER COLUMN "itemId" SET NOT NULL;
ALTER TABLE "_GlobalOptionGroupToItem"
DROP CONSTRAINT "_GlobalOptionGroupToItem_B_fkey";
ALTER TABLE "_GlobalOptionGroupToItem"
ADD CONSTRAINT "_GlobalOptionGroupToItem_itemId_fkey"
FOREIGN KEY ("itemId") REFERENCES "Item"(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE "_GlobalOptionGroupToItem"
ADD CONSTRAINT "_GlobalOptionGroupToItemp_A_itemId_unique" UNIQUE ("A", "itemId");
ALTER TABLE "_GlobalOptionGroupToItem"
DROP COLUMN "B";
ALTER TABLE "Card"
ADD CONSTRAINT "Card_id_unique" UNIQUE (id);
ALTER TABLE "_CardToMake"
ADD COLUMN "cardId" text;
UPDATE "_CardToMake" ls
SET "cardId" = CAST(i.id as uuid)
FROM "Card" i
WHERE ls."A" = i.url;
ALTER TABLE "_CardToMake"
ALTER COLUMN "cardId" SET NOT NULL;
ALTER TABLE "_CardToMake"
DROP CONSTRAINT "_CardToMake_A_fkey";
ALTER TABLE "_CardToMake"
ADD CONSTRAINT "_CardToMake_cardId_fkey"
FOREIGN KEY ("cardId") REFERENCES "Card"(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE "_CardToMake"
ADD CONSTRAINT "_CardToMake_B_itemId_unique" UNIQUE ("B", "cardId");
ALTER TABLE "_GlobalOptionGroupToItem"
DROP COLUMN "A";
_ItemToLocalOptionGroup
ALTER TABLE "_ItemToLocalOptionGroup"
ADD COLUMN "itemId" text;
UPDATE "_ItemToLocalOptionGroup" ls
SET "itemId" = CAST(i.id as uuid)
FROM "Item" i
WHERE ls."A" = i.url;
ALTER TABLE "_ItemToLocalOptionGroup"
ALTER COLUMN "itemId" SET NOT NULL;
ALTER TABLE "_ItemToLocalOptionGroup"
DROP CONSTRAINT "_ItemToLocalOptionGroup_A_fkey";
ALTER TABLE "_ItemToLocalOptionGroup"
ADD CONSTRAINT "_ItemToLocalOptionGroup_itemId_fkey"
FOREIGN KEY ("itemId") REFERENCES "Item"(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE "_ItemToLocalOptionGroup"
ADD CONSTRAINT "_ItemToLocalOptionGroup_B_itemId_unique" UNIQUE ("B", "itemId");
ALTER TABLE "_ItemToLocalOptionGroup"
DROP COLUMN "A";