updated schema so same region name can exist in differentcountries
This commit is contained in:
parent
f0125fd472
commit
7590e54392
@ -7,6 +7,7 @@ import {
|
||||
text,
|
||||
timestamp,
|
||||
uuid,
|
||||
unique,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
@ -95,11 +96,17 @@ export const subRegionsRelations = relations(subRegions, ({ many, one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const regions = createTable("region", {
|
||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||
name: text("name").notNull().unique(),
|
||||
countryId: uuid("countryId").notNull(),
|
||||
});
|
||||
export const regions = createTable(
|
||||
"region",
|
||||
{
|
||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||
name: text("name").notNull(),
|
||||
countryId: uuid("countryId").notNull(),
|
||||
},
|
||||
(t) => ({
|
||||
uniqueRegion: unique().on(t.name, t.countryId),
|
||||
}),
|
||||
);
|
||||
|
||||
export const regionsRelations = relations(regions, ({ many, one }) => ({
|
||||
wines: many(wines),
|
||||
|
Loading…
Reference in New Issue
Block a user