Skip to content

Commit bfc2e99

Browse files
committed
chore: Minor changes to dummy app migrations
1 parent 9bda446 commit bfc2e99

9 files changed

+92
-51
lines changed

spec/dummy/db/migrate/20170806125915_create_active_storage_tables.active_storage.rb

Lines changed: 0 additions & 27 deletions
This file was deleted.

spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CreateActiveAdminComments < ActiveRecord::Migration[6.0]
24
def self.up
35
create_table :active_admin_comments do |t|
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# frozen_string_literal: true
2+
# This migration comes from active_storage (originally 20170806125915)
3+
4+
class CreateActiveStorageTables < ActiveRecord::Migration[6.0]
5+
def change
6+
# Use Active Record's configured type for primary and foreign keys
7+
primary_key_type, foreign_key_type = primary_and_foreign_key_types
8+
9+
create_table :active_storage_blobs, id: primary_key_type do |t|
10+
t.string :key, null: false
11+
t.string :filename, null: false
12+
t.string :content_type
13+
t.text :metadata
14+
t.string :service_name, null: false
15+
t.bigint :byte_size, null: false
16+
t.string :checksum
17+
18+
if connection.supports_datetime_with_precision?
19+
t.datetime :created_at, precision: 6, null: false
20+
else
21+
t.datetime :created_at, null: false
22+
end
23+
24+
t.index [ :key ], unique: true
25+
end
26+
27+
create_table :active_storage_attachments, id: primary_key_type do |t|
28+
t.string :name, null: false
29+
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
30+
t.references :blob, null: false, type: foreign_key_type
31+
32+
if connection.supports_datetime_with_precision?
33+
t.datetime :created_at, precision: 6, null: false
34+
else
35+
t.datetime :created_at, null: false
36+
end
37+
38+
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
39+
t.foreign_key :active_storage_blobs, column: :blob_id
40+
end
41+
42+
create_table :active_storage_variant_records, id: primary_key_type do |t|
43+
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
44+
t.string :variation_digest, null: false
45+
46+
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
47+
t.foreign_key :active_storage_blobs, column: :blob_id
48+
end
49+
end
50+
51+
private
52+
def primary_and_foreign_key_types
53+
config = Rails.configuration.generators
54+
setting = config.options[config.orm][:primary_key_type]
55+
primary_key_type = setting || :primary_key
56+
foreign_key_type = setting || :bigint
57+
[ primary_key_type, foreign_key_type ]
58+
end
59+
end

spec/dummy/db/migrate/20180607053251_create_authors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class CreateAuthors < ActiveRecord::Migration[5.2]
3+
class CreateAuthors < ActiveRecord::Migration[6.0]
44
def change
55
create_table :authors do |t|
66
t.string :name

spec/dummy/db/migrate/20180607053254_create_profiles.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class CreateProfiles < ActiveRecord::Migration[5.2]
3+
class CreateProfiles < ActiveRecord::Migration[6.0]
44
def change
55
create_table :profiles do |t|
66
t.text :description

spec/dummy/db/migrate/20180607053255_create_tags.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class CreateTags < ActiveRecord::Migration[5.2]
3+
class CreateTags < ActiveRecord::Migration[6.0]
44
def change
55
create_table :tags do |t|
66
t.string :name

spec/dummy/db/migrate/20180607053257_create_post_tags.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class CreatePostTags < ActiveRecord::Migration[5.2]
3+
class CreatePostTags < ActiveRecord::Migration[6.0]
44
def change
55
create_table :post_tags do |t|
66
t.belongs_to :post, foreign_key: true

spec/dummy/db/migrate/20180607053739_create_posts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class CreatePosts < ActiveRecord::Migration[5.2]
3+
class CreatePosts < ActiveRecord::Migration[6.0]
44
def change
55
create_table :posts do |t|
66
t.string :title

spec/dummy/db/schema.rb

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111
# It's strongly recommended that you check this file into your version control system.
1212

1313
ActiveRecord::Schema.define(version: 2018_06_07_053739) do
14-
1514
create_table "active_admin_comments", force: :cascade do |t|
1615
t.string "namespace"
1716
t.text "body"
1817
t.string "resource_type"
19-
t.bigint "resource_id"
18+
t.integer "resource_id"
2019
t.string "author_type"
21-
t.bigint "author_id"
22-
t.datetime "created_at", precision: 6, null: false
23-
t.datetime "updated_at", precision: 6, null: false
20+
t.integer "author_id"
21+
t.datetime "created_at", null: false
22+
t.datetime "updated_at", null: false
2423
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
2524
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
2625
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
@@ -29,8 +28,8 @@
2928
create_table "active_storage_attachments", force: :cascade do |t|
3029
t.string "name", null: false
3130
t.string "record_type", null: false
32-
t.integer "record_id", null: false
33-
t.integer "blob_id", null: false
31+
t.bigint "record_id", null: false
32+
t.bigint "blob_id", null: false
3433
t.datetime "created_at", null: false
3534
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
3635
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
@@ -41,25 +40,32 @@
4140
t.string "filename", null: false
4241
t.string "content_type"
4342
t.text "metadata"
43+
t.string "service_name", null: false
4444
t.bigint "byte_size", null: false
45-
t.string "checksum", null: false
45+
t.string "checksum"
4646
t.datetime "created_at", null: false
4747
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
4848
end
4949

50+
create_table "active_storage_variant_records", force: :cascade do |t|
51+
t.bigint "blob_id", null: false
52+
t.string "variation_digest", null: false
53+
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
54+
end
55+
5056
create_table "authors", force: :cascade do |t|
5157
t.string "name"
5258
t.integer "age"
5359
t.string "email"
54-
t.datetime "created_at", null: false
55-
t.datetime "updated_at", null: false
60+
t.datetime "created_at", precision: nil, null: false
61+
t.datetime "updated_at", precision: nil, null: false
5662
end
5763

5864
create_table "post_tags", force: :cascade do |t|
5965
t.integer "post_id"
6066
t.integer "tag_id"
61-
t.datetime "created_at", null: false
62-
t.datetime "updated_at", null: false
67+
t.datetime "created_at", precision: nil, null: false
68+
t.datetime "updated_at", precision: nil, null: false
6369
t.index ["post_id"], name: "index_post_tags_on_post_id"
6470
t.index ["tag_id"], name: "index_post_tags_on_tag_id"
6571
end
@@ -70,29 +76,30 @@
7076
t.text "description"
7177
t.integer "author_id"
7278
t.string "category"
73-
t.datetime "dt"
79+
t.datetime "dt", precision: nil
7480
t.float "position"
7581
t.boolean "published"
76-
t.datetime "created_at", null: false
77-
t.datetime "updated_at", null: false
82+
t.datetime "created_at", precision: nil, null: false
83+
t.datetime "updated_at", precision: nil, null: false
7884
t.index ["author_id"], name: "index_posts_on_author_id"
7985
end
8086

8187
create_table "profiles", force: :cascade do |t|
8288
t.text "description"
8389
t.integer "author_id"
84-
t.datetime "created_at", null: false
85-
t.datetime "updated_at", null: false
90+
t.datetime "created_at", precision: nil, null: false
91+
t.datetime "updated_at", precision: nil, null: false
8692
t.index ["author_id"], name: "index_profiles_on_author_id"
8793
end
8894

8995
create_table "tags", force: :cascade do |t|
9096
t.string "name"
91-
t.datetime "created_at", null: false
92-
t.datetime "updated_at", null: false
97+
t.datetime "created_at", precision: nil, null: false
98+
t.datetime "updated_at", precision: nil, null: false
9399
end
94100

95101
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
102+
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
96103
add_foreign_key "post_tags", "posts"
97104
add_foreign_key "post_tags", "tags"
98105
add_foreign_key "posts", "authors"

0 commit comments

Comments
 (0)