Hi!
I don't know if this has been already discussed, most probably yes. But are
there any plans to implement the possibility to add constraints to existing
tables? And I'm not necessarily asking for full-blown functionality. Currently
to do that you have to drop the table and recreate it again with the
constraint. Possibly you could rename it, create the new table with the
constraint, transfer data manually from old to new and then drop the old table?
I'd be fine if this functionality behaves like that, I'd be fine even if it
just drops the table and then recreates it again, losing everything stored
inside (if it's noted in the docs with big shiny red letters that that's how it
works).
Some background... I'm a developer and we use the concept of migration files to
make changes to the DB structure. So, if a feature needs changes in the DB, we
write a new migration file which migrates its structure from the old version to
the new one. We support different DB engines to feed the service and the
migration logic is abstracted by a library which detects what DBMS is running
and constructs the appropriate SQL for it. We use SQLite just for running our
tests quickly while developing, proper instances mostly run Postgres or
something similar. When we start our tests, the DB is empty and then migrations
are run one by one to reach the needed DB structure for the application. This
is why if you were to implement adding constraints which completely wipe the
table, I personally wouldn't care (if that's easier for you). What's causing us
problems right now is that in our migration files we have to write something
approximately like { if (dbType == SQLite) { "DROP TABLE...; CREATE
TABLE...CONSTRAINT...;" } else { "ALTER TABLE ... ADD CONSTRAINT ...;" } }. If
we could use the same way of altering the DB for SQLite as for other databases,
it would help us so so much. Migrations are also used to update existing
systems with new releases whose data mustn't be wiped so going for the SQLite
approach with non-SQLite databases isn't an option. We're occasionally weighing
if SQLite is worth the hassle or should we just drop it and use something like
Postgres even for running our local tests, even though it would be slower to
run the tests (in case of a Dockerized environment) and more of a hassle to set
up. I'm sure we're not the only devs out there with these kinds of problems /
hassles.
So... Is this something we can look forward to in the near / not so near
future? Or did you already decide against it?
Best regards,Marko
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users