What kind of database refactoring tools are there? - database

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.

Related

How to synchronize work on a database project over multiple programmers?

I'm developing an app with one of my friends and it'll use an Oracle database. We can sync the code with github but what about the database? Is it possible to somehow use git for that as well?
I assume the recommended approach would be to use a central online database somehow. Where do I start with that? Docker? We are both inexperienced in web development. We also have no requirement to make the database online(it's a university course project) so I do not want to go through that hassle if possible.
You can store your SQL scripts (like your DDL commands to create your tables, etc.) in GitHub, just like any other code, but your Oracle database won't interface with it directly. You can use Oracle's SQL Developer as an IDE to interface with GitHub.
https://www.oracle.com/tools/downloads/sqldev-v192-downloads.html
https://blogs.oracle.com/shay/managing-oracle-database-code-with-sql-developer,-git,-and-developer-cloud-service
Traditional Oracle is free for academic and training purposes, and there is also a free cloud offering now as well. You can run it from a laptop, a VM using VirtualBox, or from the Oracle Cloud. Unless you need a specific option with Enterprise Edition, your best (least complicated) bet, is probably to go with the Oracle 18c XE version, available here: https://www.oracle.com/database/technologies/xe-downloads.html
We built a commerical tool that helps database developers use Git with the Oracle Database. It tracks the changes in database objects and helps you to commit them to Git. It might be worth takinga look: https: www.gitora.com

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.

Database migrations for 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.

Synchronizing Database Schemas among Developers

I'm working on a project with couple others. We all have local copies of the project, which is also constantly updated via svn repo.
Because we are in the early stage of the development, we often change the schema of our database. This leads to a lot of problem when we sync our code, because we don't have a great way to synchronize our database schemas.
What are some intuitive and easy way to sync frequently changing database schema?
We are working with CakePHP (not sure if this would help me find good solutions).
EDIT
Found some tools to do this type of work in CakePHP:
http://book.cakephp.org/view/734/Schema-management-and-migrations
And here is an additional website:
http://bakery.cakephp.org/articles/view/cake-db-migrations-v2-1
Database migrations are an easy way to keep your working databases in sync. Essentially, migrations are scripts that update a database to the latest schema and fill in the new tables with the correct data, so they are kept in a valid state.
There are few features provided by migrations:
Tools to automate the creation/update of the tables. The tools keep track of the schema version and which scripts need to be run.
Some migration tools provide ability to run code (c#, ruby, etc.) instead of sql scripts. Code libraries provided by the migration tool is usually better able to abstract the database dependent parts and make your database scripts more database independent.
There are tools available for Ruby (migrations are an important part of Rails), C# and Java. Surely, other languages also.
There are a number of questions here on migrations and I would suggest searching for a migration tool that fits in your tool chain.
CakePHP Database Migrations by Joel Moss is by far the best solution at the moment.
Project description from github:
Database Migrations for CakePHP 1.2 is a shell script supported by the CakePHP console, that lets you manage your database schema without touching one little bit of SQL. It is based on the Ruby on Rails implementation of Migrations, and uses Pear's MDB2 package, so supports all the databases that that supports.
You could think of Migrations as a version control system for your database. It's power lends itself perfectly to developing as part of a team, as each member can keep their own independent copy of their application's database, and use Migrations to make changes to its schema. All other members have to do then, is to run a simple two word shell command, and their database copy is up to date with everyone else's.
The Migrations shell will generate a migration file for each DB change you want to make. This file can include any number of DB changes.
Cake 2.x-compatible plugin on Github:
https://github.com/CakeDC/migrations
Here's a great example using Git but the same applies to SVN anyhow. http://thewebandthings.synodicsolutions.com/2009/06/13/cakephp-versioning-database-changes-with-git/
i have started a small project that we use to sync database between developers and deploy to production. Its still at an early stage, but its proven to work it just doesn't have a lot of documentation yet.
http://code.google.com/p/php-mysql-version-control/

Database compare tools

My company has a number of relatively small Access databases (2-5MB) that control our user assisted design tools. Naturally these databases evolve over time as data bugs are found and fixed and as the schema changes to support new features in the tools. Can anyone recommend a database diff tool to compare both the data and schema from one version of the database to the next? Any suggestions will be appreciated: free, open source, or commercial.
I use Red Gate Sql Compare for comparing schemas. It also has an interesting feature that allows you to save a snapshot of the schema which you can then use in later diffs. for example compare the schema of today with the schema of a month ago.
I use ApexSQL Diff. It is an excellent tool for doing just what you're describing...compare schema, compare data, generate change scripts. It not free, but it works well.
NOTE: ApexSQL Diff only works with SQL Server.
We never actually purchased it as we ended up using SQL Server 2005, but DBDiff seemed to do the trick: http://www.dkgas.com/downdbdiff.cgi
It works with any ODBC compatible DB.
I've used Total Access Detective in the past and it did the trick. It's a while ago though so you might want to investigate first...
If you're looking for a free alternative to Red Gate's most excellent SQL Compare, you might want to check SQLDBDigg made by SQLDBTools. It's what I used until I caved and bought SQL Compare.
It's not a perfect solution, but I often export both databases as txt/SQL files and then use a diff program, such as the one that comes with TortoiseSVN. You can then see all of the differences. It doesn't automatically create the SQL though to sync the dbs.
http://www.diffkit.org
Features
High performance, for large datasets (+10MM rows).
Very low memory overhead, even on very large datasets.
High quality-- comprehensive embedded regression test suite for the application/framework.
Java run everywhere (tm) — Linux, Solaris, OS X, Windows, etc.
Cross database-- Oracle, MySQL, DB2, and any JDBC datasource.
Command-line driven; no GUI needed; can run in headless environments.
XML configuration file driven.
Free Open Source Software.
Apache License, Version 2.0.
Clean Object Oriented Design make extension easy.
Easily embeddable as a Java library (jar).

Resources