Sha256: ed1df44146a2f79e886fc12bff764f3066b99f57ca6933b62ea4d0738eefa704

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

# This is necessary because if you don't include foreigner in your
# gemfile it won't load during a migration, for some reason.
require 'foreigner'; Foreigner.load

class CreateFlipperTables < ActiveRecord::Migration
  def self.up
    create_table :flipper_features do |t|
      t.string :name, null: false
      t.timestamps null: false
    end
    add_index :flipper_features, :name, unique: true

    create_table :flipper_gates do |t|
      t.integer :flipper_feature_id, null: false
      t.string :name, null: false
      t.string :value
      t.timestamps null: false
    end
    add_foreign_key :flipper_gates, :flipper_features, on_delete: :cascade
    add_index :flipper_gates, [:flipper_feature_id, :name, :value], unique: true
  end

  def self.down
    remove_foreign_key :flipper_gates, :flipper_features
    drop_table :flipper_gates
    drop_table :flipper_features
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-activerecord3dot2-0.1.2 lib/generators/flipper/templates/migration.rb