20161006213403_rails_settings_migration.rb 483 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. class RailsSettingsMigration < ActiveRecord::Migration[5.0]
  3. def up
  4. create_table :settings do |t|
  5. t.string :var, null: false
  6. t.text :value
  7. t.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' }
  8. t.timestamps null: true
  9. end
  10. add_index :settings, [:target_type, :target_id, :var], unique: true
  11. end
  12. def down
  13. drop_table :settings
  14. end
  15. end