Sha256: 1f251ed9b008675d67c828b1382caf058583ef1da8b3716b0410d6ff7b71be74

Contents?: true

Size: 650 Bytes

Versions: 5

Compression:

Stored size: 650 Bytes

Contents

class SettingsMigration < ActiveRecord::Migration
  
  def change
    
    # To support db-backed settings, we need a table containing their values
    create_table :settings_values do |t|
      # Polymorphic ownership as "context"
      t.string  'context_type', :null => false
      t.integer 'context_id'

      # Full key, ie App.settings.foo.bar.some_value => 'foo.bar.some_value'
      t.string  'full_key', :null => false

      # Serialized value
      t.text    'value'
    end
    
    # In cases where we have a lot of db-backed settings, an index is a must!
    add_index :settings_values, ['context_type', 'context_id']
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iron-settings-1.0.4 db/settings_migration.rb
iron-settings-1.0.3 db/settings_migration.rb
iron-settings-1.0.2 db/settings_migration.rb
iron-settings-1.0.1 db/settings_migration.rb
iron-settings-1.0.0 db/settings_migration.rb