| 1 | import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core"; |
| 2 | |
| 3 | export const Notes = pgTable("notes", { |
| 4 | id: serial("id").primaryKey(), |
| 5 | body: text("body").notNull(), |
| 6 | createdAt: timestamp("created_at", { withTimezone: true }) |
| 7 | .notNull() |
| 8 | .defaultNow(), |
| 9 | }); |
| 10 | |
| 11 | export type Note = typeof Notes.$inferSelect; |
| 12 | |
| 13 | export const ENSURE_NOTES_SQL = ` |
| 14 | CREATE TABLE IF NOT EXISTS notes ( |
| 15 | id serial PRIMARY KEY, |
| 16 | body text NOT NULL, |
| 17 | created_at timestamptz NOT NULL DEFAULT now() |
| 18 | ) |
| 19 | `; |