Database migrations for SQL Server - sql-server

I need a database migration framework for SQL Server, capable of managing both schema changes and data migrations.
I guess I am looking for something similar to django's South framework here.
Given the fact that South is tightly coupled with django's ORM, and the fact that there's so many ORMs for SQL Server I guess having just a generic migration framework, enabling you to write and execute in controlled and sequential manner SQL data/schema change scripts should be sufficient.

You could take a look at Wizardby (open source)

Perhaps Liquibase or dbdeploy meets your needs? I've also heard good things about RedGate.

Redgate's migrations solution in Visual Studio is ReadyRoll.
Our SSMS-based solution is SQL Source Control.

Related

Database Migration with the flyway or dbup(.net library/dbup extension) with PostgreSQL

First of all, I am sorry because it might be a stupid question but after a day research I am confused and I have a very less time to decide.
We are using TFS as a CI tool and as an SCM. And Postgresql for DB.
Planning to Automate DB with Postgresql and TFS.
Please suggest a tool for this that I can go forward with running my SQL files on specific DB as I want.
Can anyone please tell me if I use DbUp Migration Extension of TFS is it supporting Postgresql? As this link shows it only works with Microsoft SQL Server or Microsoft SQL Azure and then another Document says DbUp supports a number of different databases including Postgresql.
also, Does Flyway have support for c# and TFS ?
Most popular tools to do what you want is Liquibase and Flyway.
As I know there is only one significant difference: Flyway - plain SQL based, Liquibase - provides abstraction level based on XML, JSON or YAML as well as plain SQL. You can use abstractions (provided by Liquibase) to increase portability of your scripts.

Cheaper alternative for RedGate ReadyRoll

RedGate ReadyRoll is wonderful DB versioning tool which works like a charm. But the only one drawback - price.
I've researched what to use and found DBUp, Envolve... These tools are good but:
Doesn't have ability to define Up and Down scripts to be able apply and rollback migrations
Apply migration based on name ordering and not creation time. It's not big issue because developers could give the name based on the time but...
These tools doesn't allow to do development in different branches when developers uses not shared DB but their own and change DB schema separately. How to handle the issues when Team Lead have to switch between branches or when QA have to test feature before it goes to master - it's open question for me.
Using SSDT - as a case but it makes live very difficult if need do something with a DATA and not only with schema. What can be done very simple if use migration-based approach - becomes really big issue when try to do it with state-based one.
Can somebody suggest some tool for DB versioning with migration-based approach which can work with .NET stack and been free or paid but cheaper than RedGate?
Thanks
P.S.
What if use Entity Framework only for migrations? Without entities, etc. Create DB Context and do everything just to create migration files which has Up/Down and then write there scripts or define sql file to apply up/down migration changes. The only question - it's snapshots. How it will works with it.
Have somebody used this approach?
ReadyRoll also comes in a Core Edition, which is a free
entitlement if you also own a Visual Studio Enterprise license. I
admit this information isn't too helpful if you have VS Community or
Professional.
I'm updating this answer because Redgate no longer supports ReadyRoll Core edition. Instead Redgate's supported migrations tech is Flyway migrations, which comes with a free community edition.
We have decided to use EF Code First migrations to do what we need. If compare it with DbUp - EF Code First migrations contains Down script which allows us rollback DB to any target migration script.
Yes, it's not alternative for ReadyRoll and I have to accept that there are no any similar product which is surprised for me.
But it does what we need and after more than 1 month of usage I can say - it fit for our needs.
Because we we use EF Code First only for migrations scripts there is no issue with Team Collaboration described here because snapshot is always the same if your context doesn't have any entities.

Are there any good tools for SQL Server database design static analysis?

I'm interested in the existence of any tools which can perform static analysis against a SQL Server database. In essence, I'm looking for the DB equivalent of FxCop or NDepend; something which can inspect the data layer and come back with recommendations around metrics such as design, naming and any other measurable attributes relating to quality.
Has anyone used a tool in the past that can provide some design feedback? Thanks.
If you use SQL 2008, or have an instance of SQL 2008 anywhere, you can use policy based management. This will do what you want. Check Here This will work for naming and other standards, but might not work on data metrics.
You can alway use the Microsoft Best Practices analyzer for SQL
DataCleaner http://datacleaner.eobjects.org/
SQL Enlight is a dedicated static analysis tool for SQL Server, working in SSMS as well as part of Continuous Integration. There is a review on Simple Talk by Grant Fritchey. There are numerous built-in tests as well as a capability (albeit complicated looked) to author one's own checks.
SQL Cop is another option. It's not as sophisticated as SQL Enlight, and can't be automated as part of a build process, but is free.

Way to abstract database schema creation?

I'd like the ability to create a schema for multiple database types such as MySQL, SQL Server, and PostgreSQL. I know ORM tools such as Hibernate can do this, but I won't be using an ORM to access the database so would like a solution that doesn't depend on one. Are there any tools that can do this?
Edit:
I forgot to mention that this is a personal project so I'm looking for something either cheep or free.
Take a look at Erwin.
Edit: (Based on question update)
Yeah Erwin is not going to be cheap. I did a quick search and found Toad Data Modeler, which I haven't tried but may be worth looking into:
Entity relationship diagrams - both Physical and Logical modeling (incl. inheritance)
Support for various databases (Oracle,
MS SQL Server, MySQL, Sybase Ase,
PostgreSQL, DB2)
Generation of SQL (DDL) scripts
More...
SQL Power offer a FOSS modeling tool, SQL Architect. It can generate DDL for several flavours of database. It is still technically beta (current release is 0.9.1) but it should be fine for a personal project. Find out more.
I know you said u don't want an ORM but SubSonic 3's migrations might just do the trick for you. You don't have to use the ORM just have SubSonic build itself from your database and have it as a separate class library. Then change the provider say from MSSQL to MySQL and have it rebuild itself.
PowerDesigner is a far better choice than Erwin but it too is expensive.
It took me roughly 16 hours to install the demo of Erwin, lots of failed attempts, incomprehensible error messages, help phone number which were disconnected.
PD will give you 14 day free trial.

What kind of database refactoring tools are there?

I am looking for something to integrate to my CI workflow.
I've heard of dbdeploy but I'm looking for something else. The reason I don't like dbdeploy is I don't want to install java on my server.
I would prefer of course that the solution doesn't involve stringing some shell scripts together.
Here is a feature comparison between
Flyway
Liquibase
c5-db-migration
dbdeploy
mybatis
MIGRATEdb
migrate4j
dbmaintain
AutoPatch
It's not a tool, but Ambler and Sadalage's book, Refactoring Databases: Evolutionary Database Design is quite good.
Redgate will probably do everything you need. Expensive though.
EDIT - Specifically: http://www.red-gate.com/products/sql-development/readyroll/
You mentioned that you like dbDeploy and the fact that you do not want to install java on your server. Are you aware of the .NET port of this tool?
I used this recently with a team and we were very happy with it. In our case we were targeting SQL 2000, but it could easily be configured to run against other DB platforms, including MySQL. Of course it will require you to have the .NET Framework installed on the server... if that's an acceptable prerequisite vs. the java runtime.
for those people who are interested in liquibase, but don’t like xml migrations.
Take a look at groovy-liquibase, a plugin that supports groovy migrations
Liquibase is great in structure, but misses with xml migrations. This plugin solves that problem
Possible it's not your case, but if you decide to use Java take a look at liquibase
Yep, Redgate is magic. And Not that expenssive for what it provides.
Try Agile DBRIRE for Continuous Integration workflow. It's easy to set and allows to generate test db from Dev DB. Also it allows to generate incremental DB updates for Staging and Production. The tool can compare DEV and Staging/Production DB and generate metadata and data update SQL scripts. The tool is free.
Visual Studio Team system (database edition) does some refactoring.
I read the Refactoring databases book. I think it's helpful.
But in software dev, you build tests so that you are safe refactoring. They don't touch on tests in the Refactoring Databases book, which was my big disappointment with it.
I think those tools are very good, but for my purpose I have written a custom own. The main reason for this was because of I'm working on a SQL Server Compact 3.5 database, so none of the listed tools worked.
Of course it isn't as powerful as the tools from Redgate but you get the most important features very quick.
It's able to rename all kinds of database objects and migrating columns to other tables and create a diff script for 2 databases.
An important part of Refactoring Databases is the migrations part.
A .NET migrations solution that does not require EF or Java is Rob Reynold's Roundhouse
Might be worth checking out.

Resources