Skip to content

Commit f0dd744

Browse files
committed
rails active_storage:update
1 parent 014ea1c commit f0dd744

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This migration comes from active_storage (originally 20190112182829)
2+
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
3+
def up
4+
unless column_exists?(:active_storage_blobs, :service_name)
5+
add_column :active_storage_blobs, :service_name, :string
6+
7+
if configured_service = ActiveStorage::Blob.service.name
8+
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
9+
end
10+
11+
change_column :active_storage_blobs, :service_name, :string, null: false
12+
end
13+
end
14+
15+
def down
16+
remove_column :active_storage_blobs, :service_name
17+
end
18+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This migration comes from active_storage (originally 20191206030411)
2+
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
3+
def change
4+
create_table :active_storage_variant_records do |t|
5+
t.belongs_to :blob, null: false, index: false
6+
t.string :variation_digest, null: false
7+
8+
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
9+
t.foreign_key :active_storage_blobs, column: :blob_id
10+
end
11+
end
12+
end

db/schema.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# of editing this file, please use the migrations feature of Active Record to
33
# incrementally modify your database, and then regenerate this schema definition.
44
#
5-
# This file is the source Rails uses to define your schema when running `rails
6-
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
5+
# This file is the source Rails uses to define your schema when running `bin/rails
6+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
77
# be faster and is potentially less error prone than running all of your
88
# migrations from scratch. Old migrations may fail to apply correctly if those
99
# migrations use external dependencies or application code.
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2021_07_05_005416) do
13+
ActiveRecord::Schema.define(version: 2021_07_29_092030) do
1414

1515
create_table "active_storage_attachments", force: :cascade do |t|
1616
t.string "name", null: false
@@ -27,12 +27,19 @@
2727
t.string "filename", null: false
2828
t.string "content_type"
2929
t.text "metadata"
30-
t.bigint "byte_size", null: false
30+
t.integer "byte_size", null: false
3131
t.string "checksum", null: false
3232
t.datetime "created_at", null: false
33+
t.string "service_name", null: false
3334
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
3435
end
3536

37+
create_table "active_storage_variant_records", force: :cascade do |t|
38+
t.bigint "blob_id", null: false
39+
t.string "variation_digest", null: false
40+
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
41+
end
42+
3643
create_table "api_keys", force: :cascade do |t|
3744
t.integer "user_id"
3845
t.string "key"
@@ -3637,6 +3644,7 @@
36373644
end
36383645

36393646
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
3647+
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
36403648
add_foreign_key "api_keys", "users"
36413649
add_foreign_key "api_requests", "application_integrations"
36423650
add_foreign_key "api_requests", "integration_authorizations"

0 commit comments

Comments
 (0)