Problem description:
In our project we have one "production database" and many "devs". We want to know how we can manage and install the changes. We already have some procedures but it takes a lot of time and sometimes causes errors.
We can't lose data - so we can't use "drop table". We can only use "alter table".
Our actual "db versioning procedure" is like this:
When a developer wants to commit a new revision on SVN he needs to change_script.sql by adding a block:
if ([acctual_version].version < "23")) {
--- sql script ----
updateVersionTo("23")
end if
When we want to upgrade the database schema we just "execute" the change_scripts.sql
Does anyone have a better idea?
Database version control is the practice of tracking every change made to the database by every team member. Like application version control, database version control acts as a single source of truth. It empowers you with complete visibility, traceability, and continuous monitoring of the changes in your database.
What is database versioning? Database versioning begins with database schema, the structure of the database. In order to effectively version a database, you need to track and understand the changes that are happening.
Pachyderm is a data and model versioning platform that helps data scientists and Machine Learning engineers store different versions of training data in an orderly fashion, offering you traceability through the different changes your data goes through.
Red Gate's Sql Compare tool can compare two tables (or two collections of DDL scripts, or one set of scripts to a table, etc) and generate the migration script for you.
If you're working in Ruby you can look into "Ruby Migrations", which is a formalized way of doing DB versioning in code. (There are similar things in .NET such as RikMigrations and Fluent Migrator, and I'm sure similar things exist for other platforms as well).
As Randy Minder said, you can also use VS DB Edition to manage your schema for you, although I think the RedGate tools work just as easily and don't tie you to a specific platform or IDE.
I do it very similarly, but use database extended properties instead of a table to track metadata version and the upgrade steps are defined in application, rather than a single script. Most upgrade steps are just execute script Upgrade.vX.Y.sql
.
I actually find your approach superior to schema comparison tools (and that includes VS DB deployment) for several reasons:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With