Add purchase location to the database

This commit is contained in:
Gregoo 2025-01-28 21:10:14 +01:00
parent d541b1b351
commit 3d896c6d65

View File

@ -9,9 +9,14 @@ ALTER TABLE "bricktracker_sets" RENAME TO "bricktracker_sets_old";
-- Create a Bricktracker set storage table for later -- Create a Bricktracker set storage table for later
CREATE TABLE "bricktracker_set_storages" ( CREATE TABLE "bricktracker_set_storages" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL, "name" TEXT NOT NULL,
PRIMARY KEY("id") PRIMARY KEY("name")
);
-- Create a Bricktracker set storage table for later
CREATE TABLE "bricktracker_set_purchase_locations" (
"name" TEXT NOT NULL,
PRIMARY KEY("name")
); );
-- Re-Create a Bricktracker set table with the simplified name -- Re-Create a Bricktracker set table with the simplified name
@ -22,10 +27,12 @@ CREATE TABLE "bricktracker_sets" (
"theme" TEXT, -- Custom theme name "theme" TEXT, -- Custom theme name
"storage" TEXT, -- Storage bin location "storage" TEXT, -- Storage bin location
"purchase_date" INTEGER, -- Purchase data "purchase_date" INTEGER, -- Purchase data
"purchase_location" TEXT, -- Purchase location
"purchase_price" REAL, -- Purchase price "purchase_price" REAL, -- Purchase price
PRIMARY KEY("id"), PRIMARY KEY("id"),
FOREIGN KEY("set") REFERENCES "rebrickable_sets"("set"), FOREIGN KEY("set") REFERENCES "rebrickable_sets"("set"),
FOREIGN KEY("storage") REFERENCES "bricktracker_set_storages"("id") FOREIGN KEY("storage") REFERENCES "bricktracker_set_storages"("name"),
FOREIGN KEY("purchase_location") REFERENCES "bricktracker_set_purchase_locations"("name")
); );
-- Insert existing sets into the new table -- Insert existing sets into the new table