add active storage

This commit is contained in:
João Geonizeli
2021-08-04 20:35:26 -03:00
parent 41e3119953
commit 95079e2ae7
4 changed files with 82 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ gem "sass-rails", ">= 6"
gem "turbolinks", "~> 5"
gem "webpacker", "~> 5.0"
gem "bootsnap", ">= 1.4.4", require: false
gem "image_processing", "~> 1.12"
gem "devise"
gem "devise-i18n"

View File

@@ -121,6 +121,9 @@ GEM
multi_xml (>= 0.5.2)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
@@ -150,6 +153,7 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0704)
mini_magick (4.11.0)
mini_mime (1.1.0)
mini_portile2 (2.6.1)
minitest (5.14.4)
@@ -257,6 +261,8 @@ GEM
rubocop-shopify (2.2.0)
rubocop (~> 1.18)
ruby-progressbar (1.11.0)
ruby-vips (2.1.2)
ffi (~> 1.12)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
@@ -323,6 +329,7 @@ DEPENDENCIES
graphql
graphql_playground-rails
httparty
image_processing (~> 1.12)
listen (~> 3.3)
pg (~> 1.1)
pry-byebug

View File

@@ -0,0 +1,43 @@
# frozen_string_literal: true
# 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.string(:service_name, null: false)
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
# rubocop:disable Rails/CreateTableWithTimestamps
create_table(:active_storage_variant_records) do |t|
t.belongs_to(:blob, null: false, index: false)
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
# rubocop:enable Rails/CreateTableWithTimestamps
end
end

32
db/schema.rb generated
View File

@@ -10,11 +10,39 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_08_04_230323) do
ActiveRecord::Schema.define(version: 2021_08_04_233306) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", 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
end
create_table "active_storage_blobs", force: :cascade 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", null: false
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 "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
@@ -36,4 +64,6 @@ ActiveRecord::Schema.define(version: 2021_08_04_230323) do
t.index ["email"], name: "index_users_on_email", unique: true
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"
end