Improve SQLite migrations for adding/removing NOT NULL and CHECK constraints
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
### What problem are you trying to solve?
Currently, adding/removing NOT NULL and CHECK constraints performs a [table rebuild](https://learn.microsoft.com/en-us/ef/core/providers/sqlite/limitations#migrations-limitations) in SQLite. It would be more efficient to use `ALTER TABLE` statements.
### Describe the solution you'd like
The table rebuild could be simplified by issuing much simpler `ALTER TABLE` statements instead.
This is new in [SQLite 3.53.0](https://sqlite.org/releaselog/3_53_0.html) (see 3.a.)
> New SQL language features: Enhance [ALTER TABLE](https://sqlite.org/lang_altertable.html) to permit adding and removing NOT NULL and CHECK constraints.
Note that this would probably require to detect the actual SQLite version being used to know if the new `ALTER TABLE` statements can be used or if it must fallback to a table rebuild, which might be tricky.
Contributor guide
Assessment
This issue has not been assessed yet.