added onDelete cascade on regions, subregions, producers and wines
This commit is contained in:
parent
aa209bc0a8
commit
013c80791e
@ -21,7 +21,9 @@ export const producers = createTable(
|
|||||||
name: text("name").notNull().unique(),
|
name: text("name").notNull().unique(),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
imageUrl: text("imageUrl"),
|
imageUrl: text("imageUrl"),
|
||||||
countryId: uuid("countryId").notNull(),
|
countryId: uuid("countryId")
|
||||||
|
.references(() => countries.id, { onDelete: "cascade" })
|
||||||
|
.notNull(),
|
||||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||||
updatedAt: timestamp("updatedAt").defaultNow(),
|
updatedAt: timestamp("updatedAt").defaultNow(),
|
||||||
},
|
},
|
||||||
@ -52,7 +54,9 @@ export const wines = createTable("wine", {
|
|||||||
type: typeEnum("type").notNull(),
|
type: typeEnum("type").notNull(),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
imageUrl: text("imageUrl"),
|
imageUrl: text("imageUrl"),
|
||||||
producerId: uuid("producerId").notNull(),
|
producerId: uuid("producerId")
|
||||||
|
.references(() => producers.id, { onDelete: "cascade" })
|
||||||
|
.notNull(),
|
||||||
subRegionId: uuid("subRegionId"),
|
subRegionId: uuid("subRegionId"),
|
||||||
regionId: uuid("regionId").notNull(),
|
regionId: uuid("regionId").notNull(),
|
||||||
countryId: uuid("countryId").notNull(),
|
countryId: uuid("countryId").notNull(),
|
||||||
@ -87,7 +91,9 @@ export const subRegions = createTable(
|
|||||||
{
|
{
|
||||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||||
name: text("name").notNull().unique(),
|
name: text("name").notNull().unique(),
|
||||||
regionId: uuid("regionId").notNull(),
|
regionId: uuid("regionId")
|
||||||
|
.references(() => regions.id, { onDelete: "cascade" })
|
||||||
|
.notNull(),
|
||||||
},
|
},
|
||||||
(t) => ({
|
(t) => ({
|
||||||
uniqueSubRegion: unique().on(t.name, t.regionId),
|
uniqueSubRegion: unique().on(t.name, t.regionId),
|
||||||
@ -107,7 +113,9 @@ export const regions = createTable(
|
|||||||
{
|
{
|
||||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
countryId: uuid("countryId").notNull(),
|
countryId: uuid("countryId")
|
||||||
|
.references(() => countries.id, { onDelete: "cascade" })
|
||||||
|
.notNull(),
|
||||||
},
|
},
|
||||||
(t) => ({
|
(t) => ({
|
||||||
uniqueRegion: unique().on(t.name, t.countryId),
|
uniqueRegion: unique().on(t.name, t.countryId),
|
||||||
|
Loading…
Reference in New Issue
Block a user