File tree 3 files changed +8
-4
lines changed
3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " create-t3-app " : minor
3
+ ---
4
+
5
+ Change drizzle with PostgresQL to use identity columns
Original file line number Diff line number Diff line change 4
4
import { sql } from "drizzle-orm" ;
5
5
import {
6
6
index ,
7
+ integer ,
7
8
pgTableCreator ,
8
- serial ,
9
9
timestamp ,
10
10
varchar ,
11
11
} from "drizzle-orm/pg-core" ;
@@ -21,7 +21,7 @@ export const createTable = pgTableCreator((name) => `project1_${name}`);
21
21
export const posts = createTable (
22
22
"post" ,
23
23
{
24
- id : serial ( "id" ) . primaryKey ( ) ,
24
+ id : integer ( "id" ) . primaryKey ( ) . generatedByDefaultAsIdentity ( ) ,
25
25
name : varchar ( "name" , { length : 256 } ) ,
26
26
createdAt : timestamp ( "created_at" , { withTimezone : true } )
27
27
. default ( sql `CURRENT_TIMESTAMP` )
Original file line number Diff line number Diff line change 4
4
integer ,
5
5
pgTableCreator ,
6
6
primaryKey ,
7
- serial ,
8
7
text ,
9
8
timestamp ,
10
9
varchar ,
@@ -22,7 +21,7 @@ export const createTable = pgTableCreator((name) => `project1_${name}`);
22
21
export const posts = createTable (
23
22
"post" ,
24
23
{
25
- id : serial ( "id" ) . primaryKey ( ) ,
24
+ id : integer ( "id" ) . primaryKey ( ) . generatedByDefaultAsIdentity ( ) ,
26
25
name : varchar ( "name" , { length : 256 } ) ,
27
26
createdById : varchar ( "created_by" , { length : 255 } )
28
27
. notNull ( )
You can’t perform that action at this time.
0 commit comments