Can SVN copy sqlite?
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 SQLite that I can use SVN to开发者_如何学C copy it along with all my other code? Isn't that the kind of database SQLite is, just one file?
Thanks.
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.
Yes, it's just one file, but there are issues with managing it via svn:
- It's a binary format, which svn won't handle gracefully.
- If it is in use during commits, you may not commit a consistent version of the database.
- If it is in use during updates, you may corrupt your database.
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.
精彩评论