Class: GrouppedSettingsMigration

Inherits:
MIGRATION_BASE_CLASS
  • Object
show all
Defined in:
lib/generators/templates/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



25
26
27
# File 'lib/generators/templates/migration.rb', line 25

def self.down
  drop_table :groupped_settings_records
end

.upObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/templates/migration.rb', line 11

def self.up
  create_table :groupped_settings_records do |t|
    t.string :group, index: true, null: true

    if t.respond_to? :jsonb
      t.jsonb :settings, null: false, default: {}
    else
      t.json :settings, null: false, default: {}
    end

    t.belongs_to :target, polymorphic: true, type: :string, index: true, null: true
  end
end