Class: McflyMigration
- Inherits:
-
Object
- Object
- McflyMigration
- Defined in:
- lib/mcfly/migration.rb
Direct Known Subclasses
Constant Summary collapse
- TRIGS =
[INSERT_TRIG, UPDATE_TRIG, DELETE_TRIG]
Instance Method Summary collapse
- #add_sql(table_name, include_const) ⇒ Object
- #create_table(table_name, options = {}, &block) ⇒ Object
-
#migrate(direction) ⇒ Object
TODO: Remove this in 4.0 since we can check direction.
Instance Method Details
#add_sql(table_name, include_const) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/mcfly/migration.rb', line 15 def add_sql(table_name, include_const) sql_list = self.class::TRIGS + (include_const ? [self.class::CONSTRAINT] : []) sql_list.each { |sql| execute sql % {table: table_name} } end |
#create_table(table_name, options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mcfly/migration.rb', line 30 def create_table(table_name, = {}, &block) super { |t| t.integer :group_id, null: false # can't use created_at/updated_at as those are automatically # filled by ActiveRecord. t. :created_dt, null: false t. :obsoleted_dt, null: false t.references :user, null: false t.references :o_user block.call(t) } add_sql(table_name, true) if @dir == :up end |
#migrate(direction) ⇒ Object
TODO: Remove this in 4.0 since we can check direction
25 26 27 28 |
# File 'lib/mcfly/migration.rb', line 25 def migrate(direction) @dir = direction super end |