Skip to content

Commit

Permalink
fix: use PostgreSQL identity columns with drizzle (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
devotoare authored Oct 26, 2024
1 parent fe85a23 commit 54b6648
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-bags-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

Change drizzle with PostgresQL to use identity columns
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { sql } from "drizzle-orm";
import {
index,
integer,
pgTableCreator,
serial,
timestamp,
varchar,
} from "drizzle-orm/pg-core";
Expand All @@ -21,7 +21,7 @@ export const createTable = pgTableCreator((name) => `project1_${name}`);
export const posts = createTable(
"post",
{
id: serial("id").primaryKey(),
id: integer("id").primaryKey().generatedByDefaultAsIdentity(),
name: varchar("name", { length: 256 }),
createdAt: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
integer,
pgTableCreator,
primaryKey,
serial,
text,
timestamp,
varchar,
Expand All @@ -22,7 +21,7 @@ export const createTable = pgTableCreator((name) => `project1_${name}`);
export const posts = createTable(
"post",
{
id: serial("id").primaryKey(),
id: integer("id").primaryKey().generatedByDefaultAsIdentity(),
name: varchar("name", { length: 256 }),
createdById: varchar("created_by", { length: 255 })
.notNull()
Expand Down

0 comments on commit 54b6648

Please sign in to comment.