Sha256: ee05ca3b7b48887d2bfdf59c6b905f13cb72ddcb07a3c93f8a2b5a14c10d1514

Contents?: true

Size: 930 Bytes

Versions: 2

Compression:

Stored size: 930 Bytes

Contents

class McflyMigration < ActiveRecord::Migration
  INSERT_TRIG, UPDATE_TRIG, UPDATE_APPEND_ONLY_TRIG, DELETE_TRIG =
    %w{insert_trig update_trig update_append_only_trig delete_trig}.map { |f|
    File.read(File.dirname(__FILE__) + "/#{f}.sql")
  }

  TRIGS = [INSERT_TRIG, UPDATE_TRIG, DELETE_TRIG]

  def create_table(table_name, options = {}, &block)
    super { |t|
      t.integer :group_id, null: false
      # can't use created_at/updated_at as those are automatically
      # filled by ActiveRecord.
      t.timestamp :created_dt, null: false
      t.timestamp :obsoleted_dt, null: false
      t.references :user, null: false
      t.references :o_user
      block.call(t)
    }

    self.class::TRIGS.each {|sql| execute sql % {table: table_name}}
  end
end

class McflyAppendOnlyMigration < McflyMigration
  # append-only update trigger disallows updates
  TRIGS = [INSERT_TRIG, UPDATE_APPEND_ONLY_TRIG, DELETE_TRIG]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mcfly-0.0.7 lib/mcfly/migration.rb
mcfly-0.0.6 lib/mcfly/migration.rb