Skip to content

Commit

Permalink
Update schema.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
armans-code committed Oct 18, 2024
1 parent 64f61a8 commit 51266bb
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,40 @@ import { integer, numeric, pgTable, serial, text } from "drizzle-orm/pg-core";

export const collections = pgTable("collections", {
id: serial("id").primaryKey(),
title: text("name").notNull(),
name: text("name").notNull(),
slug: text("slug").notNull(),
});

export const categories = pgTable("categories", {
id: serial("id").primaryKey(),
title: text("name").notNull(),
slug: text("slug").notNull(),
slug: text("slug").notNull().primaryKey(),
name: text("name").notNull(),
collection_id: integer("collection_id")
.notNull()
.references(() => collections.id, { onDelete: "cascade" }),
});

export const subcollection = pgTable("subcollections", {
id: serial("id").primaryKey(),
title: text("name").notNull(),
slug: text("slug").notNull(),
name: text("name").notNull(),
category_id: integer("category_id")
.notNull()
.references(() => categories.id, { onDelete: "cascade" }),
.references(() => categories.slug, { onDelete: "cascade" }),
});

export const subcategories = pgTable("subcategories", {
id: serial("id").primaryKey(),
title: text("name").notNull(),
slug: text("slug").notNull(),
slug: text("slug").notNull().primaryKey(),
name: text("name").notNull(),
subcollection_id: integer("subcollection_id")
.notNull()
.references(() => subcollection.id, { onDelete: "cascade" }),
});

export const products = pgTable("products", {
id: serial("id").primaryKey(),
slug: text("slug").notNull().primaryKey(),
name: text("name").notNull(),
description: text("description").notNull(),
slug: text("slug").notNull(),
price: numeric("price").notNull(),
subcategory_id: integer("subcategory_id")
.notNull()
.references(() => subcategories.id, { onDelete: "cascade" }),
.references(() => subcategories.slug, { onDelete: "cascade" }),
});

0 comments on commit 51266bb

Please sign in to comment.