Two questions -- creating a second DB when there are existing migrations

1 view
Skip to first unread message

cjh

unread,
Dec 21, 2008, 2:08:23 PM12/21/08
to Autobase
1) Do you have an example of how to express preconditions in your DSL?

2) I'm asking, as they may be part of the answer to my real question:

Suppose I've got my web application working and have gone through
several GORM changes and Autobase change sets during its life cycle.
Now I have a new client, and I want to install my app for them. Since
their database isn't going to have experienced all the point releases
the first database did, there are going to be a bunch of migrations in
the changelog file that make will probably cause errors if they were
run. What's the best way to handle this?

One thing I can think of is to be defensive and try to put appropriate
preconditions on every migration I create. That sounds like a great
idea in theory, but I can see it would be a pain and would be pretty
error-prone.

Alternatively, I could tell the database to ignore all the migrations
already in the changelog the very first time the app is run using the
new database. That seems like a safer approach. If so, is there any
particular way to do this within Autobase, or should I fake it out by
copying the Liquibase tables from the original database into the new
one?

Thanks,
Chris

Robert Fischer

unread,
Dec 21, 2008, 7:03:32 PM12/21/08
to grails-...@googlegroups.com
1) Not yet. I should write one up. The short answer is:

// Corresponding to http://www.liquibase.org/manual/preconditions
preConditions { // Thank Liquibase for the funny spelling
dbms(type:'oracle')
runningAs(username:'SYSTEM')
}

2) You've pretty much hit the nail on the head. First, establish preConditions, so that you're not
assuming anything about the state of the database when the migration is fired: you should be able to
go from an empty database, through a full set of migrations, and end up with someone you like. For
an entirely new client, it'd probably be easier to wipe out all the non-constructive migration
scripts and just use HBM2DDL to provide the baseline.

Copying over the table is probably not a great idea. Lying to Autobase about the state of the
database seems highly dubious.

~~ Robert.
--
~~ Robert Fischer.
Grails Trainining http://www.smokejumperit.com/grails_training.html
Smokejumper Consulting http://smokejumperit.com
Enfranchised Mind Blog http://enfranchisedmind.com/blog
Reply all
Reply to author
Forward
0 new messages