about summary refs log tree commit diff stats
path: root/db
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-07-02 18:03:37 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-07-03 14:01:41 -0400
commit49b11f2864f75bcfb8d0d01439939ed68aa90b8f (patch)
treec91d0976e9cb54562aa2c19f9648235d74f14cbf /db
parentcb01d13034ad41a29533b623cbbf7c23b37a231c (diff)
downloadthoughts-49b11f2864f75bcfb8d0d01439939ed68aa90b8f.tar.gz
thoughts-49b11f2864f75bcfb8d0d01439939ed68aa90b8f.tar.bz2
thoughts-49b11f2864f75bcfb8d0d01439939ed68aa90b8f.zip
Collapsed Entry -> Blog single-table inheritance to Blog
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180702214240_rename_entries_to_blogs.rb24
-rw-r--r--db/schema.rb45
2 files changed, 46 insertions, 23 deletions
diff --git a/db/migrate/20180702214240_rename_entries_to_blogs.rb b/db/migrate/20180702214240_rename_entries_to_blogs.rb new file mode 100644 index 0000000..eac2e6a --- /dev/null +++ b/db/migrate/20180702214240_rename_entries_to_blogs.rb
@@ -0,0 +1,24 @@
1class RenameEntriesToBlogs < ActiveRecord::Migration[5.1]
2 def up
3 rename_table :entries, :blogs
4
5 remove_column :blogs, :type
6
7 Record.where(recordable_type: "Entry").each do |r|
8 r.recordable_type = "Blog"
9 r.save!
10 end
11 end
12
13 def down
14 rename_table :blogs, :entries
15
16 add_column :entries, :type, :string, null: false, default: "Blog"
17 change_column_default :entries, :type, nil
18
19 Record.where(recordable_type: "Blog").each do |r|
20 r.recordable_type = "Entry"
21 r.save!
22 end
23 end
24end
diff --git a/db/schema.rb b/db/schema.rb index 868f6f6..e036b75 100644 --- a/db/schema.rb +++ b/db/schema.rb
@@ -10,9 +10,17 @@
10# 10#
11# It's strongly recommended that you check this file into your version control system. 11# It's strongly recommended that you check this file into your version control system.
12 12
13ActiveRecord::Schema.define(version: 20180130021851) do 13ActiveRecord::Schema.define(version: 20180702214240) do
14 14
15 create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 15 create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
16 t.string "title"
17 t.text "body"
18 t.string "slug", null: false
19 t.datetime "created_at", null: false
20 t.datetime "updated_at", null: false
21 end
22
23 create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
16 t.string "data_file_name", null: false 24 t.string "data_file_name", null: false
17 t.string "data_content_type" 25 t.string "data_content_type"
18 t.integer "data_file_size" 26 t.integer "data_file_size"
@@ -25,16 +33,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
25 t.index ["type"], name: "index_ckeditor_assets_on_type" 33 t.index ["type"], name: "index_ckeditor_assets_on_type"
26 end 34 end
27 35
28 create_table "entries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 36 create_table "pokeviewer_abilities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
29 t.string "title"
30 t.text "body"
31 t.string "slug", null: false
32 t.string "type", null: false
33 t.datetime "created_at", null: false
34 t.datetime "updated_at", null: false
35 end
36
37 create_table "pokeviewer_abilities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
38 t.string "name", null: false 37 t.string "name", null: false
39 t.string "description", null: false 38 t.string "description", null: false
40 t.datetime "created_at", null: false 39 t.datetime "created_at", null: false
@@ -42,13 +41,13 @@ ActiveRecord::Schema.define(version: 20180130021851) do
42 t.index ["name"], name: "index_pokeviewer_abilities_on_name", unique: true 41 t.index ["name"], name: "index_pokeviewer_abilities_on_name", unique: true
43 end 42 end
44 43
45 create_table "pokeviewer_gift_ribbons", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 44 create_table "pokeviewer_gift_ribbons", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
46 t.string "description", null: false 45 t.string "description", null: false
47 t.datetime "created_at", null: false 46 t.datetime "created_at", null: false
48 t.datetime "updated_at", null: false 47 t.datetime "updated_at", null: false
49 end 48 end
50 49
51 create_table "pokeviewer_items", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 50 create_table "pokeviewer_items", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
52 t.string "name", null: false 51 t.string "name", null: false
53 t.boolean "tm", default: false, null: false 52 t.boolean "tm", default: false, null: false
54 t.integer "move_id" 53 t.integer "move_id"
@@ -60,13 +59,13 @@ ActiveRecord::Schema.define(version: 20180130021851) do
60 t.index ["move_id"], name: "index_pokeviewer_items_on_move_id" 59 t.index ["move_id"], name: "index_pokeviewer_items_on_move_id"
61 end 60 end
62 61
63 create_table "pokeviewer_locations", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 62 create_table "pokeviewer_locations", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
64 t.string "name", null: false 63 t.string "name", null: false
65 t.datetime "created_at", null: false 64 t.datetime "created_at", null: false
66 t.datetime "updated_at", null: false 65 t.datetime "updated_at", null: false
67 end 66 end
68 67
69 create_table "pokeviewer_moves", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 68 create_table "pokeviewer_moves", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
70 t.string "name", null: false 69 t.string "name", null: false
71 t.integer "pp", null: false 70 t.integer "pp", null: false
72 t.datetime "created_at", null: false 71 t.datetime "created_at", null: false
@@ -78,7 +77,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
78 t.index ["name"], name: "index_pokeviewer_moves_on_name", unique: true 77 t.index ["name"], name: "index_pokeviewer_moves_on_name", unique: true
79 end 78 end
80 79
81 create_table "pokeviewer_pokedex_entries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 80 create_table "pokeviewer_pokedex_entries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
82 t.bigint "trainer_id" 81 t.bigint "trainer_id"
83 t.bigint "species_id" 82 t.bigint "species_id"
84 t.boolean "caught", default: false 83 t.boolean "caught", default: false
@@ -89,7 +88,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
89 t.index ["trainer_id"], name: "index_pokeviewer_pokedex_entries_on_trainer_id" 88 t.index ["trainer_id"], name: "index_pokeviewer_pokedex_entries_on_trainer_id"
90 end 89 end
91 90
92 create_table "pokeviewer_pokemon", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 91 create_table "pokeviewer_pokemon", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
93 t.string "uuid", null: false 92 t.string "uuid", null: false
94 t.integer "trainer_id" 93 t.integer "trainer_id"
95 t.string "key" 94 t.string "key"
@@ -116,7 +115,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
116 t.index ["uuid"], name: "index_pokeviewer_pokemon_on_uuid", unique: true 115 t.index ["uuid"], name: "index_pokeviewer_pokemon_on_uuid", unique: true
117 end 116 end
118 117
119 create_table "pokeviewer_revisions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 118 create_table "pokeviewer_revisions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
120 t.integer "pokemon_id", null: false 119 t.integer "pokemon_id", null: false
121 t.integer "sequential_id", null: false 120 t.integer "sequential_id", null: false
122 t.string "nickname", null: false 121 t.string "nickname", null: false
@@ -172,7 +171,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
172 t.index ["species_id"], name: "index_pokeviewer_revisions_on_species_id" 171 t.index ["species_id"], name: "index_pokeviewer_revisions_on_species_id"
173 end 172 end
174 173
175 create_table "pokeviewer_species", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 174 create_table "pokeviewer_species", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
176 t.string "name", null: false 175 t.string "name", null: false
177 t.datetime "created_at", null: false 176 t.datetime "created_at", null: false
178 t.datetime "updated_at", null: false 177 t.datetime "updated_at", null: false
@@ -183,7 +182,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
183 t.index ["name"], name: "index_pokeviewer_species_on_name", unique: true 182 t.index ["name"], name: "index_pokeviewer_species_on_name", unique: true
184 end 183 end
185 184
186 create_table "pokeviewer_trainers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 185 create_table "pokeviewer_trainers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
187 t.string "game", null: false 186 t.string "game", null: false
188 t.string "name", null: false 187 t.string "name", null: false
189 t.integer "number", null: false 188 t.integer "number", null: false
@@ -220,7 +219,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
220 t.index ["world_ribbon_id"], name: "index_pokeviewer_trainers_on_world_ribbon_id" 219 t.index ["world_ribbon_id"], name: "index_pokeviewer_trainers_on_world_ribbon_id"
221 end 220 end
222 221
223 create_table "records", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 222 create_table "records", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
224 t.text "description" 223 t.text "description"
225 t.string "recordable_type" 224 t.string "recordable_type"
226 t.integer "recordable_id" 225 t.integer "recordable_id"
@@ -229,7 +228,7 @@ ActiveRecord::Schema.define(version: 20180130021851) do
229 t.index ["recordable_type", "recordable_id"], name: "index_records_on_recordable_type_and_recordable_id" 228 t.index ["recordable_type", "recordable_id"], name: "index_records_on_recordable_type_and_recordable_id"
230 end 229 end
231 230
232 create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 231 create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
233 t.string "login", default: "", null: false 232 t.string "login", default: "", null: false
234 t.string "email", default: "", null: false 233 t.string "email", default: "", null: false
235 t.string "encrypted_password", default: "", null: false 234 t.string "encrypted_password", default: "", null: false