about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-07 13:17:56 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-07 13:17:56 +0200
commit06016453bd91882a53e91c11fc80f2c75fd474bb (patch)
tree1effbffae4db31206aff69efecb431407f70a924 /db/migrate
parent943c69c65d6410d1689d4494c9214c90654db56b (diff)
Adding user settings (model and mailer), no form yet
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