diff --git a/spec/dummy/db/migrate/20170806125915_create_active_storage_tables.active_storage.rb b/spec/dummy/db/migrate/20170806125915_create_active_storage_tables.active_storage.rb deleted file mode 100644 index 0b2ce25..0000000 --- a/spec/dummy/db/migrate/20170806125915_create_active_storage_tables.active_storage.rb +++ /dev/null @@ -1,27 +0,0 @@ -# This migration comes from active_storage (originally 20170806125915) -class CreateActiveStorageTables < ActiveRecord::Migration[5.2] - def change - create_table :active_storage_blobs do |t| - t.string :key, null: false - t.string :filename, null: false - t.string :content_type - t.text :metadata - t.bigint :byte_size, null: false - t.string :checksum, null: false - t.datetime :created_at, null: false - - t.index [ :key ], unique: true - end - - create_table :active_storage_attachments do |t| - t.string :name, null: false - t.references :record, null: false, polymorphic: true, index: false - t.references :blob, null: false - - t.datetime :created_at, null: false - - t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - end -end diff --git a/spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb b/spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb index 0332a27..f854cad 100644 --- a/spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb +++ b/spec/dummy/db/migrate/20180101010101_create_active_admin_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateActiveAdminComments < ActiveRecord::Migration[6.0] def self.up create_table :active_admin_comments do |t| diff --git a/spec/dummy/db/migrate/20180101010102_create_active_storage_tables.active_storage.rb b/spec/dummy/db/migrate/20180101010102_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..df16c54 --- /dev/null +++ b/spec/dummy/db/migrate/20180101010102_create_active_storage_tables.active_storage.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true +# This migration comes from active_storage (originally 20170806125915) + +class CreateActiveStorageTables < ActiveRecord::Migration[6.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :active_storage_blobs, id: primary_key_type do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.string :service_name, null: false + t.bigint :byte_size, null: false + t.string :checksum + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments, id: primary_key_type do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + t.references :blob, null: false, type: foreign_key_type + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + + create_table :active_storage_variant_records, id: primary_key_type do |t| + t.belongs_to :blob, null: false, index: false, type: foreign_key_type + t.string :variation_digest, null: false + + t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [ primary_key_type, foreign_key_type ] + end +end diff --git a/spec/dummy/db/migrate/20180607053251_create_authors.rb b/spec/dummy/db/migrate/20180607053251_create_authors.rb index c9b8593..67b1e9a 100644 --- a/spec/dummy/db/migrate/20180607053251_create_authors.rb +++ b/spec/dummy/db/migrate/20180607053251_create_authors.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateAuthors < ActiveRecord::Migration[5.2] +class CreateAuthors < ActiveRecord::Migration[6.0] def change create_table :authors do |t| t.string :name diff --git a/spec/dummy/db/migrate/20180607053254_create_profiles.rb b/spec/dummy/db/migrate/20180607053254_create_profiles.rb index ddd2df0..06f87b9 100644 --- a/spec/dummy/db/migrate/20180607053254_create_profiles.rb +++ b/spec/dummy/db/migrate/20180607053254_create_profiles.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateProfiles < ActiveRecord::Migration[5.2] +class CreateProfiles < ActiveRecord::Migration[6.0] def change create_table :profiles do |t| t.text :description diff --git a/spec/dummy/db/migrate/20180607053255_create_tags.rb b/spec/dummy/db/migrate/20180607053255_create_tags.rb index bade84e..c95b197 100644 --- a/spec/dummy/db/migrate/20180607053255_create_tags.rb +++ b/spec/dummy/db/migrate/20180607053255_create_tags.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateTags < ActiveRecord::Migration[5.2] +class CreateTags < ActiveRecord::Migration[6.0] def change create_table :tags do |t| t.string :name diff --git a/spec/dummy/db/migrate/20180607053257_create_post_tags.rb b/spec/dummy/db/migrate/20180607053257_create_post_tags.rb index bbcfee6..0938fd6 100644 --- a/spec/dummy/db/migrate/20180607053257_create_post_tags.rb +++ b/spec/dummy/db/migrate/20180607053257_create_post_tags.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreatePostTags < ActiveRecord::Migration[5.2] +class CreatePostTags < ActiveRecord::Migration[6.0] def change create_table :post_tags do |t| t.belongs_to :post, foreign_key: true diff --git a/spec/dummy/db/migrate/20180607053739_create_posts.rb b/spec/dummy/db/migrate/20180607053739_create_posts.rb index c6a9322..be3fb82 100644 --- a/spec/dummy/db/migrate/20180607053739_create_posts.rb +++ b/spec/dummy/db/migrate/20180607053739_create_posts.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreatePosts < ActiveRecord::Migration[5.2] +class CreatePosts < ActiveRecord::Migration[6.0] def change create_table :posts do |t| t.string :title diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index dd072f2..b31dd4b 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -11,16 +11,15 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 2018_06_07_053739) do - create_table "active_admin_comments", force: :cascade do |t| t.string "namespace" t.text "body" t.string "resource_type" - t.bigint "resource_id" + t.integer "resource_id" t.string "author_type" - t.bigint "author_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.integer "author_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id" t.index ["namespace"], name: "index_active_admin_comments_on_namespace" t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id" @@ -29,8 +28,8 @@ ActiveRecord::Schema.define(version: 2018_06_07_053739) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false - t.integer "record_id", null: false - t.integer "blob_id", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false t.datetime "created_at", null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true @@ -41,25 +40,32 @@ ActiveRecord::Schema.define(version: 2018_06_07_053739) do t.string "filename", null: false t.string "content_type" t.text "metadata" + t.string "service_name", null: false t.bigint "byte_size", null: false - t.string "checksum", null: false + t.string "checksum" t.datetime "created_at", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end + create_table "active_storage_variant_records", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + create_table "authors", force: :cascade do |t| t.string "name" t.integer "age" t.string "email" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false end create_table "post_tags", force: :cascade do |t| t.integer "post_id" t.integer "tag_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["post_id"], name: "index_post_tags_on_post_id" t.index ["tag_id"], name: "index_post_tags_on_tag_id" end @@ -70,29 +76,30 @@ ActiveRecord::Schema.define(version: 2018_06_07_053739) do t.text "description" t.integer "author_id" t.string "category" - t.datetime "dt" + t.datetime "dt", precision: nil t.float "position" t.boolean "published" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["author_id"], name: "index_posts_on_author_id" end create_table "profiles", force: :cascade do |t| t.text "description" t.integer "author_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["author_id"], name: "index_profiles_on_author_id" end create_table "tags", force: :cascade do |t| t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "post_tags", "posts" add_foreign_key "post_tags", "tags" add_foreign_key "posts", "authors"