Drizzle ORM use postgres serial type with start value

105 Views Asked by At

I started with Drizzle ORM, I'm creating first user.ts schema:

import { pgTable, serial } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
 id: serial("id").primaryKey(),
});

I stacked with having the start value of this sequence users_id_seq without having to modify the db directly

I tried to modify the generated sql file that generated by drizzle:

CREATE TABLE IF NOT EXISTS "users" (
"id" serial PRIMARY KEY NOT NULL
);
ALTER SEQUENCE users_id_seq RESTART WITH 10000;

But when I run drizzle command push:pg only create table statement runs

Is there any workaround using Drizzle ORM directly ?

0

There are 0 best solutions below