Hi everyone! Is there a way to enforce prisma mig...
# orm-help
m
Hi everyone! Is there a way to enforce prisma migrate to generate BIGINT instead of BIGSERIAL for ids?
model Denomination {
id         BigInt      @unique @default(autoincrement()) @db.BigInt
symbol     String      @unique
active     Boolean
createdAt  DateTime    @default(now()) @map("created_at") @db.Timestamp(5)
updatedAt  DateTime    @default(now()) @map("updated_at") @db.Timestamp(5)
@@map("denomination")
}
Running prisma migrate, generates the following sql scrcipt
-- CreateTable
CREATE TABLE "denomination" (
"id" BIGSERIAL NOT NULL, -- Here I want BIGINT insted of BIGSERIAL
"symbol" TEXT NOT NULL,
"active" BOOLEAN NOT NULL,
"created_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Thanks in advance!
j
Unfortunately not right now. That we use
SERIAL
or its equivalents is baked in right now.
What is the use case behind you wanting to modify this?
(You can of course modify the generated migration - but that will probably be changed each time you create a new migration again 😞 )
👀 1
m
Hey @janpio, thanks for responding. Firstly, it is a best practice that Postgres suggest that serial type shouldn't be used. In my case I need to use that
BIGINT
for security reasons. Also found this issue on GitHub, I will change it by hand for now, but it would be great to have a customizable feature for this type of issue.
j
Yes, we know - but as we support older Postgres versions as well, we do not really have a choice until we start to generate different migrations for different versions - which comes with its own set of problems.
If you would use
BIGINT
, how would the sequence be defined then for the field which you request via
@default(autoincrement())
?