Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
refactor(nuxt): user schema in postgresjs.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 22, 2023
1 parent fd5b51a commit 586cc76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ export function createDrizzleConfig(data: {
}) {
const indexSchema = /* ts */`// Pergel auto generated please change this file as you wish
import { pgTable, uuid, varchar } from 'drizzle-orm/pg-core'
// This pergel auth feature is not yet implemented. Do not use it. It will be implemented in the future.
import { defaultUserSchema } from '@pergel/nuxt/drizzle/schema/pg'
import { sql } from 'drizzle-orm'
export const user = defaultUserSchema({})
export const user = pgTable('user', {
...defaultUserSchema,
})
export const hello = pgTable('hello', {
id: uuid('id').primaryKey().default(sql\`uuid_generate_v4()\`),
Expand Down
15 changes: 6 additions & 9 deletions packages/nuxt/src/runtime/modules/drizzle/templates/pg.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { sql } from 'drizzle-orm'
import { type PgTableFn, pgTable, uuid, varchar } from 'drizzle-orm/pg-core'
import { uuid, varchar } from 'drizzle-orm/pg-core'

export function defaultUserSchema(column: Parameters<PgTableFn>[1]) {
return pgTable('user', {
id: uuid('id').primaryKey().default(sql`uuid_generate_v4()`),
email: varchar('email').unique().notNull(),
password: varchar('password').notNull(),
name: varchar('name').notNull(),
...column,
})
export const defaultUserSchema = {
id: uuid('id').primaryKey().default(sql`uuid_generate_v4()`),
email: varchar('email').unique().notNull(),
password: varchar('password').notNull(),
name: varchar('name').notNull(),
}

0 comments on commit 586cc76

Please sign in to comment.