feat: migrate globalItems — drop brand text, add manufacturerId FK
This commit is contained in:
4
drizzle-pg/0008_productive_tyrannus.sql
Normal file
4
drizzle-pg/0008_productive_tyrannus.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE "global_items" ADD COLUMN "manufacturer_id" integer NOT NULL REFERENCES "manufacturers"("id");--> statement-breakpoint
|
||||||
|
ALTER TABLE "global_items" DROP CONSTRAINT "global_items_brand_model_unique";--> statement-breakpoint
|
||||||
|
ALTER TABLE "global_items" DROP COLUMN "brand";--> statement-breakpoint
|
||||||
|
ALTER TABLE "global_items" ADD CONSTRAINT "global_items_manufacturer_id_model_unique" UNIQUE("manufacturer_id","model");
|
||||||
1697
drizzle-pg/meta/0008_snapshot.json
Normal file
1697
drizzle-pg/meta/0008_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -57,6 +57,13 @@
|
|||||||
"when": 1776516850497,
|
"when": 1776516850497,
|
||||||
"tag": "0007_steady_sasquatch",
|
"tag": "0007_steady_sasquatch",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 8,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1776521936465,
|
||||||
|
"tag": "0008_productive_tyrannus",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,9 @@ export const globalItems = pgTable(
|
|||||||
"global_items",
|
"global_items",
|
||||||
{
|
{
|
||||||
id: serial("id").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
brand: text("brand").notNull(),
|
manufacturerId: integer("manufacturer_id")
|
||||||
|
.notNull()
|
||||||
|
.references(() => manufacturers.id),
|
||||||
model: text("model").notNull(),
|
model: text("model").notNull(),
|
||||||
category: text("category"),
|
category: text("category"),
|
||||||
weightGrams: doublePrecision("weight_grams"),
|
weightGrams: doublePrecision("weight_grams"),
|
||||||
@@ -193,7 +195,7 @@ export const globalItems = pgTable(
|
|||||||
cropY: doublePrecision("crop_y"),
|
cropY: doublePrecision("crop_y"),
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
},
|
},
|
||||||
(table) => [unique().on(table.brand, table.model)],
|
(table) => [unique().on(table.manufacturerId, table.model)],
|
||||||
);
|
);
|
||||||
|
|
||||||
// ── Tags ───────────────────────────────────────────────────────────
|
// ── Tags ───────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user