On Jun 8, 8:02 pm, Iain Barnett <[email protected]> wrote:
> Hi all,
>
> I want to run migrations against an in-memory sqlite3 database for testing
> with RSpec. If the contents of 001_project.rb is:
>
> Sequel.migration do
> up do
> create_table(:services, :ignore_index_errors=>true) do
> primary_key :services_id
> String :service, :size=>30, :null=>false
>
> index [:service], :name=>:uq_services, :unique=>true
> end
> end
>
> down do
> drop_table :services
> end
> end
>
> Is there a way I can run this migration in an RSpec `before` block? I would
> stick it in a system call and use the command line migration tool, but I've
> no idea what conn string I'd pass to use the same in-memory db as the spec is
> running!
>
> Just wondering. Any help or insight is much appreciated.
You can use the Sequel::Migration API:
Sequel.extension :migration
Sequel::Migration.descendants.clear
require 'migrate/001_project'
Sequel::Migration.descendants.each{|m| m.apply(DB, :up)}
You may want to give migration.rb a read:
https://github.com/jeremyevans/sequel/tree/master/lib/sequel/extensions/migration.rb
Jeremy
--
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.