1

I have 2 files, database.db and schema.sql. schema.sql is generated in the database using the command:

sqlite3 database.db < schema.sql 

The database.db is then updated dynamically locally. The question I want solved is that the version of database.db I want on my remote repository is the one that just contains the tables and table rows as declared in schema.sql. The goal here is that I don't want merge conflicts in database.db as we are multiple people working on this repository and we are likely to want to have different databases.

So far I have only tried adding database.db to the repository's .gitignore which doesn't work.

adahy
  • 25
  • 4
  • 1
    Choose a different procedure that does not require you to keep a locally modified tracked file. It only leads to major headaches as the many SO posts about [how to ignore changes in tracked file](https://stackoverflow.com/search?q=%5Bgit%5D+how+to+ignore+changes+in+tracked+file) demonstrate. – j6t Feb 16 '23 at 10:13
  • 1
    Track `schema.sql` instead of `database.db`. Maintain your own `database.db` out of the repository. – ElpieKay Feb 16 '23 at 10:15
  • Don't track the db file or check the `skip-worktree` feature https://stackoverflow.com/a/13631525/717372 – Philippe Feb 16 '23 at 11:30

1 Answers1

0

The question I want solved is that the version of database.db I want on my remote repository is the one that just contains the tables and table rows as declared in schema.sql

Then work with two different database.db files:

  • one (database.gen.sql) which is tracked and pushed, and just contains the tables and table rows as declared in schema.sql: sqlite3 database.gen.sql < schema.sql
  • one (database.sql) which is is copied from database.gen.sql and then modified privately by developers, meaning this one can be added to the .gitignore.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250