diff --git a/packages/db/src/schema/auth.ts b/packages/db/src/schema/auth.ts index 2324b445..1fccbd07 100644 --- a/packages/db/src/schema/auth.ts +++ b/packages/db/src/schema/auth.ts @@ -8,10 +8,7 @@ import { guestbook } from './guestbook' export const roleEnum = pgEnum('role', ['user', 'admin']) export const users = pgTable('user', { - id: text('id') - .notNull() - .primaryKey() - .$defaultFn(() => createId()), + id: text('id').primaryKey().$defaultFn(createId), name: text('name'), email: text('email').notNull().unique(), emailVerified: timestamp('email_verified', { precision: 3 }), @@ -48,7 +45,7 @@ export const accounts = pgTable( ) export const sessions = pgTable('session', { - sessionToken: text('session_token').notNull().primaryKey(), + sessionToken: text('session_token').primaryKey(), userId: text('user_id') .notNull() .references(() => users.id, { onDelete: 'cascade' }), diff --git a/packages/db/src/schema/comments.ts b/packages/db/src/schema/comments.ts index 519e503e..e919eef8 100644 --- a/packages/db/src/schema/comments.ts +++ b/packages/db/src/schema/comments.ts @@ -5,7 +5,7 @@ import { users } from './auth' import { posts } from './posts' export const comments = pgTable('comment', { - id: text('id').notNull().primaryKey(), + id: text('id').primaryKey(), body: text('body').notNull(), userId: text('user_id') .notNull() diff --git a/packages/db/src/schema/guestbook.ts b/packages/db/src/schema/guestbook.ts index 6ff8cd7d..b67fdd91 100644 --- a/packages/db/src/schema/guestbook.ts +++ b/packages/db/src/schema/guestbook.ts @@ -4,7 +4,7 @@ import { pgTable, text, timestamp } from 'drizzle-orm/pg-core' import { users } from './auth' export const guestbook = pgTable('guestbook', { - id: text('id').notNull().primaryKey(), + id: text('id').primaryKey(), body: text('body').notNull(), userId: text('user_id') .notNull() diff --git a/packages/db/src/schema/likes-sessions.ts b/packages/db/src/schema/likes-sessions.ts index 07d76351..727c1dd2 100644 --- a/packages/db/src/schema/likes-sessions.ts +++ b/packages/db/src/schema/likes-sessions.ts @@ -1,7 +1,7 @@ import { integer, pgTable, text, timestamp } from 'drizzle-orm/pg-core' export const likesSessions = pgTable('likes_session', { - id: text('id').notNull().primaryKey(), + id: text('id').primaryKey(), createdAt: timestamp('created_at', { precision: 3 }).notNull().defaultNow(), likes: integer('likes').notNull().default(0) }) diff --git a/packages/db/src/schema/posts.ts b/packages/db/src/schema/posts.ts index 6beea49b..6f85bc61 100644 --- a/packages/db/src/schema/posts.ts +++ b/packages/db/src/schema/posts.ts @@ -5,7 +5,7 @@ import { comments } from './comments' export const posts = pgTable('post', { createdAt: timestamp('created_at', { precision: 3 }).notNull().defaultNow(), - slug: text('slug').notNull().primaryKey(), + slug: text('slug').primaryKey(), likes: integer('likes').notNull().default(0), views: integer('views').notNull().default(0) })