Compare commits

..

2 Commits

Author SHA1 Message Date
3a10c0ad7e updated readme
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m5s
2024-05-23 20:57:14 +02:00
6418855f4e updated schema to reflect producers and wine 2024-05-23 20:55:08 +02:00
2 changed files with 37 additions and 11 deletions

View File

@ -10,7 +10,7 @@ Created with t3-app using:
TODO (in no particular order for now):
- [] Top nav
- [] define (and draw?) db schemas
- [x] define (and draw?) db schema (initial)
- [] side product nav
- [] product cards
- [] cart

View File

@ -1,16 +1,13 @@
import { drizzle } from 'drizzle-orm/vercel-postgres';
import { sql } from "@vercel/postgres";
import {
PgTimestamp,
index,
pgTableCreator,
serial,
text,
timestamp,
uniqueIndex,
uuid,
varchar,
} from "drizzle-orm/pg-core";
import { relations } from 'drizzle-orm';
/**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
@ -20,17 +17,46 @@ import {
*/
export const createTable = pgTableCreator((name) => `wine-shop_${name}`);
export const posts = createTable(
"post",
export const producers = createTable(
"producer",
{
id: uuid('id').primaryKey(),
post: text('post').notNull(),
name: text('name').notNull(),
createdAt: timestamp('createdAt').defaultNow().notNull(),
updatedAt: timestamp('updatedAt').defaultNow()
country: text('country').notNull(),
region: text('region').notNull(),
email: text('email').notNull()
},
(posts) => {
(producers) => {
return {
uniqueIdx: uniqueIndex('unique_idx').on(posts.id),
uniqueIdx: uniqueIndex('email').on(producers.email),
};
},
);
export const producersRelations = relations(producers, ({ many }) => ({
wines: many(wines),
}));
export const wines = createTable(
"wine",
{
id: uuid('id').primaryKey(),
name: text('name').notNull(),
createdAt: timestamp('createdAt').defaultNow().notNull(),
updatedAt: timestamp('updatedAt').defaultNow(),
producer: text('producer').notNull(),
},
(wines) => {
return {
uniqueIdx: uniqueIndex('unique_idx').on(wines.id),
};
},
);
export const winesRelations = relations(wines, ({ one }) => ({
producer: one(producers, {
fields: [wines.producer],
references: [producers.id],
}),
}));