SQLite Forum

IS NULL optimization on NOT NULL constraints breaks on corrupted databases
Login
>
>~~~
>PRAGMA writable_schema = boolean;
>
>When this pragma is on, and the SQLITE_DBCONFIG_DEFENSIVE flag is off, then the sqlite_schema table can be changed using ordinary UPDATE, INSERT, and DELETE statements.
>
>Warning: misuse of this pragma can easily result in a corrupt database file.
>~~~
>

see [pragma writable_schema](https://sqlite.org/pragma.html#pragma_writable_schema) in documentation.

Inserting data and then invalidating the constraints by this pragma is clearly a misuse from my point of view.
You should have cleaned the data before adaptation of the schema for this change. The schema change is not doing that.