Page 1 of 1

Model first with SQLite

Posted: Wed 23 Feb 2011 12:16
by Mystcreater
Hi,

I tried to use the model first approach with a SQLite database and when I add a column in a table and then use the option "Update Database with model", the table in the database is deleted and recreated without keeping the rows alive.

I know that SQLite don't allow deleting column on an existing table but in this case, you should create a temporary table, copy all the rows to this table, delete the table, create a new table without the deleted column, copy all the rows from the temporary table and then delete the temporary table.

Here is a sample of code from the web site of SQLite:

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;

Thank you

Posted: Thu 24 Feb 2011 15:59
by StanislavK
It is not guaranteed that the Update To Database wizard keeps data safe in all cases. Provided that the database does not support the ALTER statement needed in a particular case, the whole table will be dropped and re-created.

We will consider implementing backups for such cases in future, but cannot provide any timeframe for this.