BrickTracker/bricktracker/sql/migrations/0008.sql

30 lines
718 B
MySQL
Raw Normal View History

2025-01-27 23:07:10 +01:00
-- description: Creation of the deduplicated table of Rebrickable minifigures
2025-01-27 18:39:35 +01:00
BEGIN TRANSACTION;
2025-01-27 23:07:10 +01:00
-- Create a Rebrickable minifigures table: each unique minifigure imported from Rebrickable
CREATE TABLE "rebrickable_minifigures" (
"figure" TEXT NOT NULL,
"number" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"image" TEXT,
PRIMARY KEY("figure")
2025-01-27 18:39:35 +01:00
);
-- Insert existing sets into the new table
2025-01-27 23:07:10 +01:00
INSERT INTO "rebrickable_minifigures" (
"figure",
"number",
"name",
"image"
2025-01-27 18:39:35 +01:00
)
SELECT
"minifigures"."fig_num",
2025-01-27 23:07:10 +01:00
CAST(SUBSTR("minifigures"."fig_num", 5) AS INTEGER),
"minifigures"."name",
"minifigures"."set_img_url"
FROM "minifigures"
GROUP BY
"minifigures"."fig_num";
2025-01-27 18:39:35 +01:00
COMMIT;