Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you use source control for your database items? [closed]

People also ask

What is source control in database?

On its own, database source control introduces additional overhead as the developers are required to save the changes they've made to an object in a separate SQL script, open the source control system client, check in the SQL script file using the client and then apply the changes to the live database.

Do databases have version control?

The database version control tool needs to be able to validate SQL code with automation. Without this ability, SQL code will continue to lag behind the application code.

What is SQL Source Control?

What does SQL Source Control do? SQL Source Control plugs into SQL Server Management Studio (SSMS) and links your databases to an existing version control system, such as Git, TFS or Subversion. This allows you to manage changes to database schema and static data alongside application code.


Must read Get your database under version control. Check the series of posts by K. Scott Allen.

When it comes to version control, the database is often a second or even third-class citizen. From what I've seen, teams that would never think of writing code without version control in a million years-- and rightly so-- can somehow be completely oblivious to the need for version control around the critical databases their applications rely on. I don't know how you can call yourself a software engineer and maintain a straight face when your database isn't under exactly the same rigorous level of source control as the rest of your code. Don't let this happen to you. Get your database under version control.


The databases themselves? No

The scripts that create them, including static data inserts, stored procedures and the like; of course. They're text files, they are included in the project and are checked in and out like everything else.

Of course in an ideal world your database management tool would do this; but you just have to be disciplined about it.


I absolutely love Rails ActiveRecord migrations. It abstracts the DML to ruby script which can then be easily version'd in your source repository.

However, with a bit of work, you could do the same thing. Any DDL changes (ALTER TABLE, etc.) can be stored in text files. Keep a numbering system (or a date stamp) for the file names, and apply them in sequence.

Rails also has a 'version' table in the DB that keeps track of the last applied migration. You can do the same easily.


Check out LiquiBase for managing database changes using source control.