Hi :
This is a great question; and one that I personally have asked to other Joomla devs.
The problem is not just _joomla_. The problem is databases! They just don't lend themselves well to version controlling of content or schemas on their own.
I've done loads of reading and research on this topic and there aren't any perfect solutions (that I've found so far!) There's work arounds, and there's procedures that help.
Here's some different approaches I've learned about:
2) .git based implementation of schema changes with a custom post-git-commit hook to dump structures to a .sql in the project folder and compare them.
3) more complex versions of #2 but expanded to include content and rows (pretty annoying with large databases imho)
4) Shared database for all developers
- a single, remotely accessible database which all developers have access to, thus everyone works' on the same database
5) Dev databases with only sample content and a proper schema as a .sql which is under .git version control. Any changes are committed to the file. (basically like #1)
6) Someone I talked to actually had an idea (not sure if it ever got implemented) where they wrote a plugin for Joomla which grabbed into the onSave event hook, and basically grabbed whichever query was being run and dumped it into a file as a logger. This is great for changing menus and content and all that. Then you can take those queries and run them on a DB to get up to date.
This is probably the best way to do it if you really don't want to run remote databases. Unfortunately there's no off the shelf plugin that I know of, and any component's not using the event system will not get tracked.
What I do:
I actually do a hybrid of the shared database for live sites, while version controlling the .sql schema (not the content).
Generally its two databases, a production one and a dev one. Dev's work on new features. commit .sql changes to a file and when we launch the feature we manually run the queries to update the production database (after proper backups, of course).
This is basically the solution you already identified I think. It's not pretty or perfect, but its usable.
--
The Doctrine / ORM way:
If you've used Symfony / Doctrine or Laravel's Eloquent there's a file-based version control for schema (and content if you build that out). It's reasonably good for developers when building out apps.
Both systems ahve a form of migrations - which is basically a set of sql queries, in code (version control) which allow you to take the database through every schema it's ever been in. The only annoying thing about this is you have to kind of write those queries yourself for anything complex.
And again, not great for tracking database content, but actually wonderfully good for schemas. I wish joomla worked nicely with an ORM. Apparently there are some people using Joomla + Doctrine, which is probably wonderful when it works.
Hopefully some of this helps; I've spent a lot of time thinking about this problem and trying out different solutions. If you think of something better come find me!