views:

360

answers:

2

I'm trying to get migrations set up in Ramaze. I'm coming from doing mostly Rails stuff, but I wanted to give something else a shot. Anyway, I've got a directory in my project called "migrations" with a start.rb file and then my migrations. Here's start.rb:

require File.expand_path('../app.rb', File.dirname(__FILE__))
require 'sequel/extensions/migration.rb'

Sequel::Migrator.apply(DB, '.')

Now, first of all, I don't know why I can't just do

Sequel::Model.plugin(:migration)

instead of that long require, but it seems to be working, so I'm not worrying about it too much. The main problem is that none of my migrations actually run. It creates the schema_info table, so I know it's trying to work, but it just can't find my 000_initial_info.rb file that's right there in the same directory.

I couldn't really find any documentation on this, so this is my own solution. I'd love to hear other solutions as well if I'm just going about this all wrong. Thanks for any help!

A: 

Here's my solution:

http://github.com/mwlang/ramaze-sequel-proto-experimental

Run "rake -T" to see the various db and migrate tasks I've written."

I use this "experimental" as my ramaze project template at the moment.

Michael Lang
That looks really nice. Thanks!
+2  A: 

You can't use Sequel::Model.plugin :migration because migration is not a model plugin, it is a core extension. This will work:

Sequel.extension :migration

Sequel comes with the bin/sequel tool that you can use to run migrations with the -m switch:

sequel -m /path/to/app/migrations

Unless you have special needs, I recommend using that.

One of the problems with your setup might be that you started your migrations at 000. Start them at 001 and it may work better.

There's rdoc documentation for the Migrator:

http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Migrator.html

Jeremy Evans
I was considering using that tool, but I don't like the idea of specifying my database connection parameters on the command line when I've already written them out in my init file. Plus, I like to have access to the whole application in my migrations (Rails style).It was my crazy numbering that was screwing things up! I always number things starting with 0. :D Now it works perfectly. Thanks!