mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-28 07:44:59 +00:00
Initial commit
This commit is contained in:
24
src/models/Schema.ts
Normal file
24
src/models/Schema.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { integer, pgTable, serial, timestamp } 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(),
|
||||
});
|
||||
Reference in New Issue
Block a user