DT
Drizzle Team•2mo ago
ragokan

How can I get warning when creating "Migration" with non nullable field

When I generate migration using the command drizzle-kit generate --config ./drizzle.config.ts I don't get any warnings for new fields that is non nullable. Shouldn't it warn me or ask for a default value? The generated SQL:
ALTER TABLE "profiles" ADD COLUMN "x" varchar NOT NULL;
ALTER TABLE "profiles" ADD COLUMN "x" varchar NOT NULL;
Config has these options
verbose: true,
strict: true,
schema: './packages/schema/**/*.ts',
dialect: 'postgresql',
dbCredentials: object
verbose: true,
strict: true,
schema: './packages/schema/**/*.ts',
dialect: 'postgresql',
dbCredentials: object
4 Replies
ragokan
ragokanOP•2mo ago
I guess there isn't any option 😔
DoggeSlapper
DoggeSlapper•2mo ago
Why would it warn u? It's totally fine to have a field not null without a default If u want to enforce something to be not null, but still dont want a default value how would you do it otherwsie? It's quite common scenario
ragokan
ragokanOP•2mo ago
@DoggeSlapper but old profiles can't have non nullable field so, it will not migrate
DoggeSlapper
DoggeSlapper•2mo ago
Ah I get what u want to do. I guess you need to use a custom migration and alter name of the column then move back or u delete all nulls I dont see how dirzzle could handle this automatically
Want results from more Discord servers?
Add your server