Class: Hoardable::MigrationGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- Hoardable::MigrationGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/hoardable/migration_generator.rb
Overview
Generates a migration to create an inherited uni-temporal table of a model including Model, for the storage of versions
.
Instance Method Summary collapse
Instance Method Details
#create_function ⇒ Object
39 40 41 |
# File 'lib/generators/hoardable/migration_generator.rb', line 39 def create_function template("../functions/set_hoardable_id.sql", "db/functions/#{function_name}_v01.sql") end |
#create_triggers ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/hoardable/migration_generator.rb', line 26 def create_triggers { versions_prevent_update: singularized_table_name, set_hoardable_id: table_name, prevent_update_hoardable_id: table_name }.each do |(trigger_name, trigger_table_name)| template( "../triggers/#{trigger_name}.sql", "db/triggers/#{trigger_table_name}_#{trigger_name}_v01.sql" ) end end |
#create_versions_table ⇒ Object
19 20 21 22 23 24 |
# File 'lib/generators/hoardable/migration_generator.rb', line 19 def create_versions_table migration_template( "migration.rb.erb", "db/migrate/create_#{singularized_table_name}_versions.rb" ) end |