Migrate from ledermann/rails-settings to rails-settings-cached which allows global settings
with YAML-defined defaults. Add admin page for editing global settings. Add "site_description" setting that would show as a paragraph on the frontpage
This commit is contained in:
parent
babc6a1528
commit
b11fdc3ae3
20 changed files with 188 additions and 34 deletions
19
db/migrate/20170112154826_migrate_settings.rb
Normal file
19
db/migrate/20170112154826_migrate_settings.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class MigrateSettings < ActiveRecord::Migration
|
||||
def up
|
||||
remove_index :settings, [:target_type, :target_id, :var]
|
||||
rename_column :settings, :target_id, :thing_id
|
||||
rename_column :settings, :target_type, :thing_type
|
||||
change_column :settings, :thing_id, :integer, null: true, default: nil
|
||||
change_column :settings, :thing_type, :string, null: true, default: nil
|
||||
add_index :settings, [:thing_type, :thing_id, :var], unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :settings, [:thing_type, :thing_id, :var]
|
||||
rename_column :settings, :thing_id, :target_id
|
||||
rename_column :settings, :thing_type, :target_type
|
||||
change_column :settings, :target_id, :integer, null: false
|
||||
change_column :settings, :target_type, :string, null: false, default: ''
|
||||
add_index :settings, [:target_type, :target_id, :var], unique: true
|
||||
end
|
||||
end
|
10
db/schema.rb
10
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: 20170109120109) do
|
||||
ActiveRecord::Schema.define(version: 20170112154826) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -238,13 +238,13 @@ ActiveRecord::Schema.define(version: 20170109120109) do
|
|||
end
|
||||
|
||||
create_table "settings", force: :cascade do |t|
|
||||
t.string "var", null: false
|
||||
t.string "var", null: false
|
||||
t.text "value"
|
||||
t.string "target_type", null: false
|
||||
t.integer "target_id", null: false
|
||||
t.string "thing_type"
|
||||
t.integer "thing_id"
|
||||
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 ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true, using: :btree
|
||||
end
|
||||
|
||||
create_table "statuses", force: :cascade do |t|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue