N
Neon17mo ago
rival-black

Help with data migration

Hi I feel like this is such a newbie question - but I'm using Neon with Drizzle in a Next.js app. I've updated one of my schema and tried to push a migration through, but all I get is this error: NeonDbError: column "type" of relation "programs" contains null values at execute (C:\Users\shaed\Documents\GitHub\mina-public\node_modules@neondatabase\serverless\index.js:1546:39) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at migrate (C:\Users\shaed\Documents\GitHub\mina-public\node_modules\src\neon-http\migrator.ts:47:5) at runMigrate (C:\Users\shaed\Documents\GitHub\mina-public\src\interfaces\neon\migrate.ts:17:3) { code: '23502', sourceError: undefined } The "type" column is the new column I'm trying to add - so I feel like it's failing because there are some programs in the dB already that have null values...any other insight that might help me resolve this migration so I can keep going with my project? TIA!
2 Replies
multiple-amethyst
multiple-amethyst17mo ago
you can add a default value to the new column u added, but I think you need to delete the old migration first for this Or edit the migration sql
rival-black
rival-black17mo ago
This is one of the options ^ Your table already has existing values, that's why the migration can't be applied You either need to: - have a default value for the column - allow it to be nullable by removing the NotNull constraint, add data, then add add the constraint - empty the data in the table and apply the migration.

Did you find this page helpful?