Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

schema.ts

31 lines979 Bytes

1import { boolean, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'
2​
3export const todos = pgTable(`todos`, {
4 id: serial(`id`).primaryKey(),
5 text: text(`text`).notNull(),
6 completed: boolean(`completed`).notNull().default(false),
7 created_at: timestamp(`created_at`, { withTimezone: true })
8 .defaultNow()
9 .notNull(),
10 updated_at: timestamp(`updated_at`, { withTimezone: true })
11 .notNull()
12 .defaultNow(),
13})
14​
15export type Todo = typeof todos.$inferSelect
16export type NewTodo = typeof todos.$inferInsert
17​
18export const config = pgTable(`config`, {
19 id: serial(`id`).primaryKey(),
20 key: text(`key`).notNull().unique(),
21 value: text(`value`).notNull(),
22 created_at: timestamp(`created_at`, { withTimezone: true })
23 .notNull()
24 .defaultNow(),
25 updated_at: timestamp(`updated_at`, { withTimezone: true })
26 .notNull()
27 .defaultNow(),
28})
29​
30export type Config = typeof config.$inferSelect
31export type NewConfig = typeof config.$inferInsert