Save .sqlite with git push

I have a php application on Heroku where user data is stored in sqlite. Every time I update my php files and click them on Heroku, the local sqlite file is also updated ... which means that I am losing working data and getting startup data.

including the file in .gitignore, make sure that the file is not available for the Heroku application. it just removes the file from the remote git repository.

git update-index -assume-unchanged cannot mark sqlite file. this gives me an error saying "inability to mark file".

Need help creating sqlite file that is created once and then not updated / deleted at all. Thanx for suggestions.

+4
source share
3 answers
Edit .gitignore to match the file you want to ignore
git rm --cached /path/to/file

See here: Applying .gitignore to committed files

0
source

Adding a mask file to .gitignoreitself and does not, of course, does not delete files from a remote repository (further here ).

All in all, this is a really bad idea for keeping SQLite databases under source control (including git). The best solution for this is to create a script that, if necessary, creates a template database. This script might look like this:

database.sql:

BEGIN TRANSACTION; -- wrap everything into one transaction
-- create tables, always use NOT EXISTS:
CREATE TABLE IF NOT EXISTS items (
    item_id INTEGER AUTOINCREMENT PRIMARY KEY,
    item_name VARCHAR(32)
);
-- create indexes, always use NOT EXISTS:
CREATE INDEX IF NOT EXISTS items_item_name ON items (item_name);
-- add more CREATE TABLE and/or CREATE INDEX statements... 

COMMIT;

Then you can execute this script using the following command:

sqlite3 -init database.sql database.db ""

, database.db , . , . database.sql ( ), .

+1

... , . .gitignore, - - . , . .gitignore , sqlite , git update-index -assume- myDB.sqlite . @rkp @mvp... ... , !:)

0