about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20161006213403_rails_settings_migration.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20161006213403_rails_settings_migration.rb b/db/migrate/20161006213403_rails_settings_migration.rb
new file mode 100644
index 000000000..3bfd8af8e
--- /dev/null
+++ b/db/migrate/20161006213403_rails_settings_migration.rb
@@ -0,0 +1,21 @@
+MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
+  ActiveRecord::Migration[5.0]
+else
+  ActiveRecord::Migration
+end
+
+class RailsSettingsMigration < MIGRATION_BASE_CLASS
+  def self.up
+    create_table :settings do |t|
+      t.string     :var,    :null => false
+      t.text       :value
+      t.references :target, :null => false, :polymorphic => true
+      t.timestamps :null => true
+    end
+    add_index :settings, [ :target_type, :target_id, :var ], :unique => true
+  end
+
+  def self.down
+    drop_table :settings
+  end
+end