mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-29 00:05:04 +00:00
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { integer, pgTable, serial, timestamp, varchar } from 'drizzle-orm/pg-core';
|
|
|
|
// This file defines the structure of your database tables using the Drizzle ORM.
|
|
|
|
// To modify the database schema:
|
|
// 1. Update this file with your desired changes.
|
|
// 2. Generate a new migration by running: `npm run db:generate`
|
|
|
|
// The generated migration file will reflect your schema changes.
|
|
// It automatically run the command `db-server:file`, which apply the migration before Next.js starts in development mode,
|
|
// Alternatively, if your database is running, you can run `npm run db:migrate` and there is no need to restart the server.
|
|
|
|
// Need a database for production? Just claim it by running `npm run neon:claim`.
|
|
// Tested and compatible with Next.js Boilerplate
|
|
|
|
export const counterSchema = pgTable('counter', {
|
|
id: serial('id').primaryKey(),
|
|
count: integer('count').default(0),
|
|
updatedAt: timestamp('updated_at', { mode: 'date' })
|
|
.defaultNow()
|
|
.$onUpdate(() => new Date())
|
|
.notNull(),
|
|
createdAt: timestamp('created_at', { mode: 'date' }).defaultNow().notNull(),
|
|
});
|
|
|
|
export const adminUserSchema = pgTable('admin_users', {
|
|
id: serial('id').primaryKey(),
|
|
username: varchar('username', { length: 255 }).unique().notNull(),
|
|
passwordHash: varchar('password_hash', { length: 255 }).notNull(),
|
|
createdAt: timestamp('created_at', { mode: 'date' }).defaultNow().notNull(),
|
|
updatedAt: timestamp('updated_at', { mode: 'date' })
|
|
.defaultNow()
|
|
.$onUpdate(() => new Date())
|
|
.notNull(),
|
|
});
|