Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Review app for active_storage_migration by leio10 #356

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source "https://rubygems.org"

ruby RUBY_VERSION

DECIDIM_VERSION = { git: "https://github.com/decidim/decidim", branch: "develop" }
DECIDIM_VERSION = { git: "https://github.com/decidim/decidim", branch: "active_storage_migration" }

gem "decidim", DECIDIM_VERSION
#gem "decidim-conferences", DECIDIM_VERSION
Expand Down Expand Up @@ -36,6 +36,7 @@ group :development do
end

group :production do
gem "aws-sdk-s3", require: false
gem "fog-aws"
gem "lograge"
gem "sendgrid-ruby"
Expand Down
22 changes: 20 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/decidim/decidim
revision: 39de071f4f6c16fad8115101882b4c568dfe86f0
branch: develop
revision: c1f8db7ed0b6638a6eb59568925ec7a19d61e2a9
branch: active_storage_migration
specs:
decidim (0.25.0.dev)
decidim-accountability (= 0.25.0.dev)
Expand Down Expand Up @@ -257,6 +257,22 @@ GEM
ast (2.4.2)
autoprefixer-rails (8.6.5)
execjs
aws-eventstream (1.1.1)
aws-partitions (1.472.0)
aws-sdk-core (3.115.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.44.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.96.1)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.3)
aws-eventstream (~> 1, >= 1.0.2)
axe-core-api (4.2.1)
capybara
dumb_delegator
Expand Down Expand Up @@ -478,6 +494,7 @@ GEM
invisible_captcha (0.13.0)
rails (>= 3.2.0)
ipaddress (0.8.3)
jmespath (1.4.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -847,6 +864,7 @@ PLATFORMS
ruby

DEPENDENCIES
aws-sdk-s3
byebug
decidim!
decidim-dev!
Expand Down
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

# Store files locally.
config.active_storage.service = :local
end
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,7 @@
referer: event.payload[:referer],
}
end

# Store files on Amazon S3.
config.active_storage.service = :amazon
end
3 changes: 3 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

# Store files locally.
config.active_storage.service = :test
end
9 changes: 9 additions & 0 deletions config/initializers/active_storage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

if ENV["HEROKU_APP_NAME"].present?
ActiveSupport.on_load(:active_storage_blob) do
def key
self[:key] ||= "#{Decidim.base_uploads_path}#{self.class.generate_unique_secure_token}"
end
end
end
33 changes: 0 additions & 33 deletions config/initializers/carrierwave.rb

This file was deleted.

1 change: 0 additions & 1 deletion config/initializers/decidim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@

Rails.application.config.i18n.available_locales = Decidim.available_locales
Rails.application.config.i18n.default_locale = Decidim.default_locale

5 changes: 0 additions & 5 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

default: &default
sentry_enabled: false
aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
aws_region: <%= ENV["AWS_REGION"] %>
aws_bucket: <%= ENV["AWS_BUCKET_NAME"] %>
aws_host: <%= ENV["AWS_HOST"] %>
omniauth:
facebook:
# It must be a boolean. Remember ENV variables doesn't support booleans.
Expand Down
14 changes: 14 additions & 0 deletions config/storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local:
service: Disk
root: <%= Rails.root.join("storage") %>

test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>

amazon:
service: S3
access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
region: <%= ENV["AWS_REGION"] %>
bucket: <%= ENV["AWS_BUCKET_NAME"] %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MoveOrganizationFieldsToHeroContentBlock < ActiveRecord::Migration[5.2]
class Organization < ApplicationRecord
self.table_name = :decidim_organizations

mount_uploader :homepage_image, ::Decidim::HomepageImageUploader
mount_uploader :homepage_image, CarrierWave::Uploader::Base
end

def change
Expand Down
30 changes: 30 additions & 0 deletions db/migrate/20210630085615_create_active_storage_tables.decidim.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true
# This migration comes from decidim (originally 20210309190009)

# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
# This migration comes from decidim (originally 20210407190753)

class AllowNullOrganizationLogoColumnInOAuthApplicationsTable < ActiveRecord::Migration[6.0]
def change
change_column_null :oauth_applications, :organization_logo, true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true
# This migration comes from decidim (originally 20210419165805)

class CreateDecidimContentBlockAttachments < ActiveRecord::Migration[6.0]
def change
create_table :decidim_content_block_attachments do |t|
t.string :name
t.references :decidim_content_block, null: false, index: { name: "decidim_content_block_attachments_on_content_block" }
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
# This migration comes from decidim_participatory_processes (originally 20210415163339)

class AllowNullFileColumnInDecidimAttachmentsTable < ActiveRecord::Migration[6.0]
def change
change_column_null :decidim_attachments, :file, true
end
end
34 changes: 31 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,34 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_06_28_083105) do
ActiveRecord::Schema.define(version: 2021_06_30_085618) do

# These are extensions that must be enabled in order to support this database
enable_extension "ltree"
enable_extension "pg_trgm"
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.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 "decidim_accountability_results", id: :serial, force: :cascade do |t|
t.jsonb "title"
t.jsonb "description"
Expand Down Expand Up @@ -237,7 +258,7 @@
create_table "decidim_attachments", id: :serial, force: :cascade do |t|
t.jsonb "title", null: false
t.jsonb "description"
t.string "file", null: false
t.string "file"
t.string "content_type", null: false
t.string "file_size", null: false
t.integer "attached_to_id", null: false
Expand Down Expand Up @@ -648,6 +669,12 @@
t.index ["decidim_user_group_id"], name: "index_decidim_consultations_votes_on_decidim_user_group_id"
end

create_table "decidim_content_block_attachments", force: :cascade do |t|
t.string "name"
t.bigint "decidim_content_block_id", null: false
t.index ["decidim_content_block_id"], name: "decidim_content_block_attachments_on_content_block"
end

create_table "decidim_content_blocks", force: :cascade do |t|
t.integer "decidim_organization_id", null: false
t.string "manifest_name", null: false
Expand Down Expand Up @@ -2084,7 +2111,7 @@
t.string "name", null: false
t.string "organization_name", null: false
t.string "organization_url", null: false
t.string "organization_logo", null: false
t.string "organization_logo"
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
Expand All @@ -2110,6 +2137,7 @@
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end

add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "decidim_area_types", "decidim_organizations"
add_foreign_key "decidim_areas", "decidim_area_types", column: "area_type_id"
add_foreign_key "decidim_areas", "decidim_organizations"
Expand Down