about summary refs log tree commit diff
path: root/db
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
parent943c69c65d6410d1689d4494c9214c90654db56b (diff)
Adding user settings (model and mailer), no form yet
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20161006213403_rails_settings_migration.rb21
-rw-r--r--db/schema.rb13
2 files changed, 33 insertions, 1 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
diff --git a/db/schema.rb b/db/schema.rb
index c4421bec7..6c21013b2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 20161003145426) do
+ActiveRecord::Schema.define(version: 20161006213403) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -126,6 +126,17 @@ ActiveRecord::Schema.define(version: 20161003145426) do
     t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
   end
 
+  create_table "settings", force: :cascade do |t|
+    t.string   "var",         null: false
+    t.text     "value"
+    t.string   "target_type", null: false
+    t.integer  "target_id",   null: false
+    t.datetime "created_at"
+    t.datetime "updated_at"
+    t.index ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree
+    t.index ["target_type", "target_id"], name: "index_settings_on_target_type_and_target_id", using: :btree
+  end
+
   create_table "statuses", force: :cascade do |t|
     t.string   "uri"
     t.integer  "account_id",                  null: false