diff --git a/src/db/schema/index.ts b/src/db/schema/index.ts index c3a9c65..a1cad6c 100644 --- a/src/db/schema/index.ts +++ b/src/db/schema/index.ts @@ -1 +1 @@ -export * from './user' +export * from './todo' diff --git a/src/db/schema/todo.ts b/src/db/schema/todo.ts new file mode 100644 index 0000000..ce7b280 --- /dev/null +++ b/src/db/schema/todo.ts @@ -0,0 +1,15 @@ +import { sql } from 'drizzle-orm' +import { boolean, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core' + +export const todoTable = pgTable('todo', { + id: uuid('id').primaryKey().default(sql`uuidv7()`), + title: text('title').notNull(), + completed: boolean('completed').notNull().default(false), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + updatedAt: timestamp('updated_at', { withTimezone: true }) + .notNull() + .defaultNow() + .$onUpdateFn(() => new Date()), +}) diff --git a/src/db/schema/user.ts b/src/db/schema/user.ts deleted file mode 100644 index 1ac722e..0000000 --- a/src/db/schema/user.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { sql } from 'drizzle-orm' -import { pgTable, text, uuid } from 'drizzle-orm/pg-core' - -export const userTable = pgTable('user', { - id: uuid('id').primaryKey().default(sql`uuidv7()`), - name: text('name').notNull(), -})