schema
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 1m57s

This commit is contained in:
christian 2024-05-23 20:18:41 +02:00
parent b0fa899735
commit 8d606fd7b8
3 changed files with 18 additions and 16 deletions

View File

@ -1,10 +1,9 @@
import Link from "next/link";
export default function HomePage() { export default function HomePage() {
return ( return (
<main className=""> <main className="">
<div className="container "> <div className="container ">
<h1>Yes hello</h1> <h1>Yes hello</h1>
<p></p>
</div> </div>
</main> </main>
); );

View File

@ -3,4 +3,5 @@ import { drizzle } from 'drizzle-orm/vercel-postgres';
import { sql } from '@vercel/postgres'; import { sql } from '@vercel/postgres';
import * as schema from './schema'; import * as schema from './schema';
export const db = drizzle(sql, { schema }); export const db = drizzle(sql, { schema });

View File

@ -1,12 +1,14 @@
// Example model schema from the Drizzle docs import { drizzle } from 'drizzle-orm/vercel-postgres';
// https://orm.drizzle.team/docs/sql-schema-declaration import { sql } from "@vercel/postgres";
import { sql } from "drizzle-orm";
import { import {
PgTimestamp,
index, index,
pgTableCreator, pgTableCreator,
serial, serial,
text,
timestamp, timestamp,
uniqueIndex,
uuid,
varchar, varchar,
} from "drizzle-orm/pg-core"; } from "drizzle-orm/pg-core";
@ -21,14 +23,14 @@ export const createTable = pgTableCreator((name) => `wine-shop_${name}`);
export const posts = createTable( export const posts = createTable(
"post", "post",
{ {
id: serial("id").primaryKey(), id: uuid('id').primaryKey(),
name: varchar("name", { length: 256 }), post: text('post').notNull(),
createdAt: timestamp("created_at", { withTimezone: true }) createdAt: timestamp('createdAt').defaultNow().notNull(),
.default(sql`CURRENT_TIMESTAMP`) updatedAt: timestamp('updatedAt').defaultNow()
.notNull(), },
updatedAt: timestamp("updatedAt", { withTimezone: true }), (posts) => {
return {
uniqueIdx: uniqueIndex('unique_idx').on(posts.id),
};
}, },
(example) => ({
nameIndex: index("name_idx").on(example.name),
})
); );