Last active
August 24, 2024 19:17
-
-
Save DonerKebab/8c8d71970d84229ba561923ec21a6390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### _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 |
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";
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_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";