Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Copy migrations with a generator because `rake casino:install:migrati…
Browse files Browse the repository at this point in the history
…ons` doesn't work from Rails Engine
  • Loading branch information
joelvh committed Nov 15, 2015
1 parent 4473f4b commit 0a20215
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/casino/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InstallGenerator < Rails::Generators::Base
def install_migrations
return unless options['migration']

rake 'casino:install:migrations'
generate 'casino:migration'
end

def copy_config_files
Expand Down
25 changes: 25 additions & 0 deletions lib/generators/casino/migration_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rails/generators/active_record'

module CASino
class MigrationGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../../../../db/migrate', __FILE__)

namespace 'casino:migration'

desc 'Installs CASino migration files.'

def install
source_paths.each do |source_path|
Dir["#{source_path}/*.rb"].each do |filename|
puts "MIGRATION TEMPLATE: #{File.basename(filename)}"
migration_template File.basename(filename), "db/migrate/#{File.basename(filename).sub(/^\d+_/, '')}"
end
end
end

def self.next_migration_number(dirname)
ActiveRecord::Generators::Base.next_migration_number(dirname)
end
end
end

0 comments on commit 0a20215

Please sign in to comment.