Migrations with Warfile deployment?

View: New views
5 Messages — Rating Filter:   Alert me  

Migrations with Warfile deployment?

by Chad Woolley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We want to give a versioned WAR to customers for deployment on their
internal environment, and are wondering how to handle migrations.  It
seems like a chicken-and-egg problem - you can't fire up a new war
until you run the migrations, but you can't run migrations which are
zipped up inside the WAR.

How do others handle this?  Give them a separate executable file/jar
(with a version matching the WAR) to run manually?  Something else?

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Migrations with Warfile deployment?

by Ikai Lan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chad,

For a production application I would NEVER use this for schema changes and such, too much can go wrong. I'm used to running DB schema changes by hand. 

However, we do have a demo app we give out which will auto run a migration, since we're not talking about mission critical code. Here are the steps you will take:

1. In your web.xml.erb, define a listener. Here's an example:

  <listener>
    <listener-class>jruby.ext.StartupScriptLauncher</listener-class>
  </listener>

2. Compile this class and make sure the JAR or .class file is available to your Rails application:


(I believe my friend Jerry shameless stole this code from Nick Sieger, so credit to him)

3. Now add a script in script/startup (we load this script in line 32). This script needs to load the Rails env. Here's the script we use:


The magic here is:

ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate/", nil)

Note that when you do things this way, you run the risk of migrations not running right, etc. It may not be worth it. 

Ikai

On Tue, Sep 29, 2009 at 10:09 AM, Chad Woolley <thewoolleyman@...> wrote:
We want to give a versioned WAR to customers for deployment on their
internal environment, and are wondering how to handle migrations.  It
seems like a chicken-and-egg problem - you can't fire up a new war
until you run the migrations, but you can't run migrations which are
zipped up inside the WAR.

How do others handle this?  Give them a separate executable file/jar
(with a version matching the WAR) to run manually?  Something else?

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Migrations with Warfile deployment?

by ben.christenson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chad,

A little late in responding, but we are working on a solution to a similar problem.  We are working with a local code-hacker to build out a strategy, and the initial PoC looks good.  The general strategy we are taking is to deploy our application pre-configured with a sqlite3 database.

For installation, a customer simply deploys the war file to unpack it.  Then, when they connect to the application, it identifies that it is being run in "configuration mode" and allows an administrator to configure the database connection.  This writes the configuration to database.yml and executes ActiveRecord::Base.establish_connection.  The administrator then has an option to execute migrations.

For upgrades, we provide a "configuration backup" that basically copies out the existing database.yml.  The customer can then redeploy the war file, and load the backup to reconfigure the database.yml.

Thanks,
Ben Christenson
Developer/Analyst

Kinetic Data, Inc.

"Building a Better Service Experience"


651.556.0937
  I  www.kineticdata.com


On Tue, Sep 29, 2009 at 11:09 AM, Chad Woolley <thewoolleyman@...> wrote:
We want to give a versioned WAR to customers for deployment on their
internal environment, and are wondering how to handle migrations.  It
seems like a chicken-and-egg problem - you can't fire up a new war
until you run the migrations, but you can't run migrations which are
zipped up inside the WAR.

How do others handle this?  Give them a separate executable file/jar
(with a version matching the WAR) to run manually?  Something else?

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Migrations with Warfile deployment?

by Mike Hagedorn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chad:

This is a little long in the tooth now, but I cooked up this http://github.com/mwhagedorn/migrate_war for a project.  Basically it applys the migrations when you deploy.

HTH


On Nov 5, 2009, at 5:06 PM, Benjamin Christenson wrote:

Chad,

A little late in responding, but we are working on a solution to a similar problem.  We are working with a local code-hacker to build out a strategy, and the initial PoC looks good.  The general strategy we are taking is to deploy our application pre-configured with a sqlite3 database.

For installation, a customer simply deploys the war file to unpack it.  Then, when they connect to the application, it identifies that it is being run in "configuration mode" and allows an administrator to configure the database connection.  This writes the configuration to database.yml and executes ActiveRecord::Base.establish_connection.  The administrator then has an option to execute migrations.

For upgrades, we provide a "configuration backup" that basically copies out the existing database.yml.  The customer can then redeploy the war file, and load the backup to reconfigure the database.yml.

Thanks,
Ben Christenson
Developer/Analyst

Kinetic Data, Inc.

"Building a Better Service Experience"


651.556.0937
  I  www.kineticdata.com


On Tue, Sep 29, 2009 at 11:09 AM, Chad Woolley <thewoolleyman@...> wrote:
We want to give a versioned WAR to customers for deployment on their
internal environment, and are wondering how to handle migrations.  It
seems like a chicken-and-egg problem - you can't fire up a new war
until you run the migrations, but you can't run migrations which are
zipped up inside the WAR.

How do others handle this?  Give them a separate executable file/jar
(with a version matching the WAR) to run manually?  Something else?

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






Michael Hagedorn 
Silverchair Solutions - Agile Web Develoment
Houston, Tx       mike@...


Re: Migrations with Warfile deployment?

by straightflush@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://blog.dberg.org/2009/10/run-dbmigrate-in-jruby-without-rails.html

does that help ?

On Thu, Nov 5, 2009 at 6:12 PM, Michael Hagedorn
<mike@...> wrote:

> Chad:
> This is a little long in the tooth now, but I cooked up
> this http://github.com/mwhagedorn/migrate_war for a project.  Basically it
> applys the migrations when you deploy.
> HTH
>
> On Nov 5, 2009, at 5:06 PM, Benjamin Christenson wrote:
>
> Chad,
>
> A little late in responding, but we are working on a solution to a similar
> problem.  We are working with a local code-hacker to build out a strategy,
> and the initial PoC looks good.  The general strategy we are taking is to
> deploy our application pre-configured with a sqlite3 database.
>
> For installation, a customer simply deploys the war file to unpack it.
> Then, when they connect to the application, it identifies that it is being
> run in "configuration mode" and allows an administrator to configure the
> database connection.  This writes the configuration to database.yml and
> executes ActiveRecord::Base.establish_connection.  The administrator then
> has an option to execute migrations.
>
> For upgrades, we provide a "configuration backup" that basically copies out
> the existing database.yml.  The customer can then redeploy the war file, and
> load the backup to reconfigure the database.yml.
>
> Thanks,
> Ben Christenson
> Developer/Analyst
>
> Kinetic Data, Inc.
> "Building a Better Service Experience"
>
> 651.556.0937  I  www.kineticdata.com
>
> On Tue, Sep 29, 2009 at 11:09 AM, Chad Woolley <thewoolleyman@...>
> wrote:
>>
>> We want to give a versioned WAR to customers for deployment on their
>> internal environment, and are wondering how to handle migrations.  It
>> seems like a chicken-and-egg problem - you can't fire up a new war
>> until you run the migrations, but you can't run migrations which are
>> zipped up inside the WAR.
>>
>> How do others handle this?  Give them a separate executable file/jar
>> (with a version matching the WAR) to run manually?  Something else?
>>
>> Thanks,
>> -- Chad
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
>
>
> Michael Hagedorn
> Silverchair Solutions - Agile Web Develoment
> Houston, Tx       mike@...
> http://www.silverchairsolutions.com
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email