From 06016453bd91882a53e91c11fc80f2c75fd474bb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 7 Oct 2016 13:17:56 +0200 Subject: Adding user settings (model and mailer), no form yet --- .../20161006213403_rails_settings_migration.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 db/migrate/20161006213403_rails_settings_migration.rb (limited to 'db/migrate') 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 -- cgit