Compare commits

..

No commits in common. "3a10c0ad7e408138e7e2e07d14609b3de05490d0" and "8d606fd7b83eb054310cc7bbde79b62eee8c801f" have entirely different histories.

2 changed files with 11 additions and 37 deletions

View File

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

View File

@ -1,13 +1,16 @@
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
@ -17,46 +20,17 @@ import { relations } from 'drizzle-orm';
*/
export const createTable = pgTableCreator((name) => `wine-shop_${name}`);
export const producers = createTable(
"producer",
export const posts = createTable(
"post",
{
id: uuid('id').primaryKey(),
name: text('name').notNull(),
post: text('post').notNull(),
createdAt: timestamp('createdAt').defaultNow().notNull(),
country: text('country').notNull(),
region: text('region').notNull(),
email: text('email').notNull()
updatedAt: timestamp('updatedAt').defaultNow()
},
(producers) => {
(posts) => {
return {
uniqueIdx: uniqueIndex('email').on(producers.email),
uniqueIdx: uniqueIndex('unique_idx').on(posts.id),
};
},
);
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],
}),
}));