Class: CreateFeatureSubscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/pin_flags/install/templates/create_feature_subscriptions.rb

Instance Method Summary collapse

Instance Method Details

#downObject



16
17
18
19
20
21
# File 'lib/generators/pin_flags/install/templates/create_feature_subscriptions.rb', line 16

def down
  if table_exists?(:pin_flags_feature_subscriptions)
    remove_index :pin_flags_feature_subscriptions, name: "idx_pf_subs_on_tag_and_taggable" if index_exists?(:pin_flags_feature_subscriptions, name: "idx_pf_subs_on_tag_and_taggable")
    drop_table :pin_flags_feature_subscriptions
  end
end

#upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/pin_flags/install/templates/create_feature_subscriptions.rb', line 2

def up
  create_table :pin_flags_feature_subscriptions do |t|
    t.references :feature_tag, null: false, foreign_key: { to_table: :pin_flags_feature_tags }
    t.references :feature_taggable, polymorphic: true, null: false, index: false

    t.timestamps
  end

  add_index :pin_flags_feature_subscriptions,
            %i[feature_tag_id feature_taggable_type feature_taggable_id],
            unique: true,
            name: "idx_pf_subs_on_tag_and_taggable"
end