1

I'm trying to setup migrations using 'rom/sql/rake_task'.

Here is my sample, but sadly it isn't working as it's complaining about a missing sequel adaptor. Any assistance or direction would be appreciated?

require 'sqlite3'
require 'rom-sql'
require 'rom/sql/rake_task'

namespace :db do
  task :setup do
    ROM.setup(:sql, 'sqlite_memory')
    ROM.finalize

    ROM::SQL.migration do
      change do
        create_table(:users) do
          primary_key :id
          String :name
        end
      end
    end
  end
end
leppie
  • 115,091
  • 17
  • 196
  • 297
Dane Balia
  • 5,271
  • 5
  • 32
  • 57

2 Answers2

3

Complete example: https://github.com/gotar/sinatra-rom

after you add

require 'bundler/setup'
require 'rom/sql/rake_task'

task :setup do
  # Load ROM related stuff. You don't need to specify manually connection
end

to Rakefile you will get few Raketasks (rake -T) to list them,

and then

$ rake db:create_migration[any_name]

and in file it will create, you can add your migration.

Thats all

gotar
  • 91
  • 5
0

you may wanna try:

ROM::SQL::Migration.connection = ROM.setup(:sql, 'sqlite_memory').default.connection
ROM.finalize.env

ROM::SQL::Migration.create do
  # ...
end
Kamil Lelonek
  • 14,592
  • 14
  • 66
  • 90