Search code examples
rakerodarom-sql

Rom-sql Rake Task


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

Solution

  • 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