This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy migrations with a generator because `rake casino:install:migrati…
…ons` doesn't work from Rails Engine
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |