On 17 Jun 2011, at 18:18, Peter van Hardenberg wrote:
> The trick here is to use a database connection in a block to run the
> migrations BEFORE calling Sequel.connect for your models, roughly like this:
>
> def create_test_db
> # Recreate the database
> Sequel.connect('postgres:///') do |other_db|
> db_name = URI.parse(ENV["DATABASE_URL"]).path[1..-1]
> other_db.run("DROP DATABASE IF EXISTS #{db_name}")
> other_db.run("CREATE DATABASE #{db_name}")
> end
>
> # Migrate the DB to The Present
> Sequel.connect(ENV["DATABASE_URL"]) do |db|
> Sequel.extension :migration
> Sequel::Migrator.run(db, './migrations')
> end
> end
I'm not using ENV["DATABASE_URL"] , is that a Sequel thing or a Ruby thing (or
any other kind of thing?! :)
Regards,
Iain
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.