Reputation: 9935
We have a Rails project that uses PostgreSQL-specific queries, so it's uncomfortable to use sqlite even in development mode. The problem is, I'd love to track schema changes in database and omit running migrations on request, and I'd also love to track db-data changes with git, so that I wouldn't need to dump the db and load it on my machine. So basically I only want to do 'git pull' and see the application working with the new schema and data.
What are the possible strategies here? The only that comes to my mind is to use a simple wrapper that takes an sql-query, checks if it has any db-specific parts and rewrites it for development environment, so that we could still use sqlite. What else?
Upvotes: 1
Views: 679
Reputation: 1118
If I understand correctly, you want to be able to track both schema and data changes.
These are, in fact, two very different things -
Disclaimer - I work at OffScale :-)
Upvotes: 0
Reputation: 753455
I'm not sure I understand all the nuances of your question - particularly the comments about using SQLite vs PostgreSQL. If it is to be a multi-DBMS system, then testing with multiple systems is good; if it is to be a single-DBMS system, then working with multiple DBMS is making life pointlessly hard.
Also, you talk about tracking the schema changes in the database...is this storing the information about schema changes separately from DBMS's own system catalog, or do you really mean that you want to track database schema changes (using something outside the database - such as a VCS)?
You also talk about tracking 'DB-data changes' which I take to mean 'the data in the tables in the database'. Again, I'm not clear if you are thinking of some sort of dump of the data from the database that covers the differences between what was there, say, a day ago and what is there now, or something else.
These issues might be why you didn't get a response for over 4 hours.
When you talk about a 'simple wrapper', you are not talking about something that I'd call simple. It has to parse arbitrary SQL, work out whether any of it is DBMS-specific, and then apply rewrite rules. That is a non-trivial undertaking. Getting the wrapper called in the right places could be non-trivial too - it depends on the set of APIs you are using to access the DBMS, amongst other things.
What else?
All the above amounts to the dreaded "it depends" answer. It depends on:
It only marginally depends on your VCS or platform, fortunately.
Upvotes: 2