Jump to content
sjordi

Deploy without overwriting the DB?

Recommended Posts

Hi all,
A generic question. I'm deploying my apps with an embedded SQLite DB. Each time I compile/deploy, that existing on device DB file is overwritten by the default one.

It's fine for development. But how do you actually proceed if you want to deploy an update? If a user has the app already with personal data, I don't want her/him to lose that data.

 

Testing whether the DB already exists is not possible since it's deployed each time within the new binary.

One way would be to have all the code to check whether the DB exists. If not, programmatically create it and fill it with sample data. If it does, just check its version and apply possible structure upgrades? But it feels like this would embark a lot of code that may not really be useful.

 

How do you guys deploy news versions of your apps without overwriting exists DBs? I especially think about iOS and Android devices.

 

Thanks for any light.

Steve

Share this post


Link to post

When you add System.StartUpCopy to the project, all files deployed to the StartUp subfolder of the app are copied to the Home directory on startup - if they don't exist there.

Share this post


Link to post

Wow, never ever encountered this! Thanks a thousands
I'll investigate this a bit further more, but it looks like it does exactly what I need...
Thanks a lot.

Share this post


Link to post

Actually, I don't find it. It's not known from the compiler, and I have no trace whatsover of any file that looks like it besides a DCU file... but not seen
I'm under Alexandria...

Docwiki at Embarcadero doesn't reference it either... nor does the help...

I think I'm missing something.

Edited by sjordi

Share this post


Link to post
11 minutes ago, sjordi said:

Actually, I don't find it. It's not known from the compiler, and I have no trace whatsover of any file that looks like it besides a DCU file... but not seen
I'm under Alexandria...

Docwiki at Embarcadero doesn't reference it either... nor does the help...

I think I'm missing something.

 

In Delphi 11, it is in C:\Program Files (x86)\Embarcadero\Studio\22.0\source\rtl\common\System.StartUpCopy.pas in my installation.

Help and doc - ehm... Did not find them.

  • Like 1

Share this post


Link to post

ok,

I think I faced a border effect... I copied the System.StartUpCopy from here and pasted it into my IDE.
Didn't work. Some extra characters? No idea. Then, I erased it, typed System. and saw StartupCopy in the completion list, selected it and still, the IDE was complaining, not even possible to compile.
Then I typed it in manually and it was fine.

Just tried to redeploy my app and I correctly kept my actual data. Cool

 

Thanks all.

Steve

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×