The reason that you cannot use git for that is that it was never intended for live data and stuff that resides on a database. That said, I agree with you that all table DDLs and stored procedures should be kept under version control. And in fact I do keep them under VC on my database. How do I do this? I have a directory in which I keep all my SQL scripts, and this directory is a git repo. In this directory/project I keep: 1. For every table that is created on the database, I have an SQL script file with the DDL that creates it 2. For every stored proc that I create, I put it in its own SQL script as well 3. For any (relatively) static lookup tables (i.e. state-region associations, etc.), they are put in a SQL script This workflow gives me several important benefits, including: 1. Everything needed to recreate the database is kept under version control, including the DDL, stored procedures and lookup tables 2. This script folder does not need to reside on the DB server, can be kept anywhere, even on my local laptop; I pull them up in DataGrip and run them on the server (my scripts are on my laptop) 3. All these scripts are VC'd under git 4. They are easily and quickly pushed to my remote repo on Github and Bitbucket for backup 5. When I need to create a new fresh, empty copy of the database somewhere, I just run these scripts and it is done quickly and easily One more little trick I have is to use Gitkraken for my git GUI. It. is free, and is absolutely the best git GUI available. The devs made it an absolute joy to use, and I never need to use the command line anymore. Hope this helps!
|