Can't alter column from `.notNull()` to `allow null`

Background I have an SQLite db, and a schema.
// schema.ts
export const T1 = sqliteTable(
'T1',
{
// ...
C1: text('C1').notNull(),
// ...
},
);
// schema.ts
export const T1 = sqliteTable(
'T1',
{
// ...
C1: text('C1').notNull(),
// ...
},
);
I edited my schema to:
// schema.ts
export const T1 = sqliteTable(
'T1',
{
// ...
C1: text('C1'),
// ...
},
);
// schema.ts
export const T1 = sqliteTable(
'T1',
{
// ...
C1: text('C1'),
// ...
},
);
Aim Assuming the business logic is correct, I aimed to migrate my database with drizzle-kit generate and <apply migration script>. Problem However, after running the generate script, no migration was generated. How can I make C1 allow NULL values? Environment
"drizzle-kit": "^0.23.0",
"drizzle-orm": "^0.31.0",
"drizzle-kit": "^0.23.0",
"drizzle-orm": "^0.31.0",
Related SEO tags so others can find the problem and the solution quicker: NOT NULL constraint failed
1 Reply
lettucebaran
lettucebaranOP6mo ago
i have lots of foreign key constraints, and they have ON DELETE CASCADE. At this point, I regret using an SQLite db when i try to disable foreign key constaint with PRAGMA foreign_keys = OFF;, then drizzle-kit throws an error: FOREIGN KEY constraint failed PARTIALLY SOLVED I created a new custom migration script. Steps:
add new column
copy data from current column to new column
drop current column
rename new column to current column
add new column
copy data from current column to new column
drop current column
rename new column to current column
Want results from more Discord servers?
Add your server