tags:

views:

43

answers:

3

my goal is to have a CMS that is totally self-contained like a flat-file CMS but still having database features. Am I correct that if I have a CMS based on sqllite that I can use SVN to copy it along with all my other code? Isn't that the kind of database sqllite is, just one file?

Thanks.

A: 

Yeah you can put the sqlite file into version control, but remember that this file is binary, so you lose some advantages of version control (such as diffs), and the format might not be compatible between different versions of sqlite.

I would still put the original SQL code used to create that database in the repository.

Matias Valdenegro
+1  A: 

Yes, it's just one file, but there are issues with managing it via svn:

  1. It's a binary format, which svn won't handle gracefully.
  2. If it is in use during commits, you may not commit a consistent version of the database.
  3. If it is in use during updates, you may corrupt your database.
Marcelo Cantos
Hm, i expect db file to be write-locked during use, so svn update would just fail to modify it. (But first 2 points certainly apply.)
Constantin
Point 3 most certainly applies. I just corrupted an open database using vi.
Marcelo Cantos
+1  A: 

Short answer: yes.

SQLite databases are contained in one file, containing both the schema specification and the data.

That's where you need to be careful if you include it in an SVN repository, and intend to distribute the software as is. You might find yourself distributing data that is not meant to be visible to the end user.

Therefore, I'd recommend to have a text file containing the SQL schema of the database, and a script that will bootstrap the creation of the database file using default data, allowing you not to put the binary sqlite file in svn.

SirDarius
I don't understand. What would I distribute that I did not mean to. thanks.
johnny
Usernames, passwords, and e-mails that you might have setup for testing might be in your sqllite DB file. You want to make sure you do not commit or distribute your testing data or any live data by including the database file in SVN.
bot403