Hi all, I face a problem which is the following, I have added in my sqlite database new columns and new tables which in some cases are Related. How can I add from my old database the records to the new one using script code ? When I copy the old sqlite database it crash in the folder of the program. So my idea was to fix a small program that will add in the old sqlite database the new columns and tables with the relations. Or is there another way? In any case its a good time to learn how to convert our database with new tables and columns.
Please your help.
I'm thinking you already deployed your application to your client or you are using it.
I handle problem like this by saving a version number to the database (something like `settings`.`dbVersion`). Then, I created script to handle the alter queries. You need to carefully document each changes in your database
From the script.pas, I am indicating a CONST variable e.g.
CONST DBVER = 2; // this is the current version on the development database. I always change this manually on the dev database to avoid error when developing.
Then, executing the db revision checking on the begin end. area
procedure DBREVISION(); var currVer: Integer; begin currVer := := SQLExecute('SELECT COALESCE(dbVersion, 0) AS currVer FROM settings WHERE 1 LIMIT 1'); if currVer < DBVER then begin if DBVER < 1 then begin // alteration of the version 1 end; if DBVER < 2 then begin // alteration of the version 2 end; SQLExecute('UPDATE `settings` SET dbVersion='+IntToStr(DBVER)); end; end; begin DBREVISION; end.
I hope this can give you an idea on how handle your problem