[odb-users] Migration issues with on_delete(set_null) constraint

Boris Kolpackov boris at codesynthesis.com
Thu Jun 22 09:58:38 EDT 2017


Anton Paymyshev <anton.paymyshev at gmail.com> writes:

> There is also odb::migrate_schema_2(...) method which adds ptr column but
> ***NO*** ON DELETE SET NULL constraint:
>           db.execute ("ALTER TABLE \"S\"\n"
>                       "  ADD COLUMN \"ptr\" INTEGER NULL CONSTRAINT
> \"ptr_fk\" REFERENCES \"S\" (\"id\")");

Thanks for the test, I could reproduce the problem.

SQLite has limited ALTER TABLE support. Specifically, a constraint
cannot be added by itself, only as part of the column. So we have
to hack around this but apparently we didn't hack far enough. I've
now fixed it:

http://scm.codesynthesis.com/?p=odb/odb.git;a=commit;h=e783a1120b174bac40697000d218796ddf421dfe

The patch is pretty simple and should apply cleanly to previous versions.
Alternatively, I can package another pre-release.

Boris



More information about the odb-users mailing list