2025-01-24 10:36:24 +01:00
|
|
|
-- description: Migrate the Bricktracker sets
|
|
|
|
|
|
|
|
PRAGMA foreign_keys = ON;
|
|
|
|
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
|
2025-01-28 10:49:47 +01:00
|
|
|
-- Create a Bricktracker set table: with their unique IDs, and a reference to the Rebrickable set
|
2025-01-24 10:36:24 +01:00
|
|
|
CREATE TABLE "bricktracker_sets" (
|
|
|
|
"id" TEXT NOT NULL,
|
|
|
|
"rebrickable_set" TEXT NOT NULL,
|
|
|
|
PRIMARY KEY("id"),
|
|
|
|
FOREIGN KEY("rebrickable_set") REFERENCES "rebrickable_sets"("set")
|
|
|
|
);
|
|
|
|
|
|
|
|
-- Insert existing sets into the new table
|
|
|
|
INSERT INTO "bricktracker_sets" (
|
|
|
|
"id",
|
|
|
|
"rebrickable_set"
|
|
|
|
)
|
|
|
|
SELECT
|
|
|
|
"sets"."u_id",
|
|
|
|
"sets"."set_num"
|
|
|
|
FROM "sets";
|
|
|
|
|
|
|
|
COMMIT;
|