Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed May 9, 2024
1 parent 10eec0e commit d7c13bf
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
# indexable :boolean default(FALSE), not null
# master_settings :jsonb
# remote_pending :boolean default(FALSE), not null
# avatar_file_size :bigint(8)
# header_file_size :bigint(8)
# avatar_file_size :integer
# header_file_size :integer
#

class Account < ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/models/custom_emoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# aliases :jsonb
# is_sensitive :boolean default(FALSE), not null
# license :string
# image_file_size :bigint(8)
# image_file_size :integer
#

class CustomEmoji < ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/models/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# data_updated_at :datetime
# account_id :bigint(8) not null
# overwrite :boolean default(FALSE), not null
# data_file_size :bigint(8)
# data_file_size :integer
#

# NOTE: This is a deprecated model, only kept to not break ongoing imports
Expand Down
4 changes: 2 additions & 2 deletions app/models/media_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# thumbnail_content_type :string
# thumbnail_updated_at :datetime
# thumbnail_remote_url :string
# file_file_size :bigint(8)
# thumbnail_file_size :bigint(8)
# file_file_size :integer
# thumbnail_file_size :integer
#

class MediaAttachment < ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/models/preview_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# link_type :integer
# published_at :datetime
# image_description :string default(""), not null
# image_file_size :bigint(8)
# image_file_size :integer
#

class PreviewCard < ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/models/site_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# blurhash :string
# file_file_size :bigint(8)
# file_file_size :integer
#

class SiteUpload < ApplicationRecord
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

require_relative '../../lib/mastodon/migration_helpers'

class RevertMediaFileSizeColumnToBigInt < ActiveRecord::Migration[7.1]
include Mastodon::MigrationHelpers

TABLE_COLUMN_MAPPING = [
[:accounts, :avatar_file_size],
[:accounts, :header_file_size],
[:custom_emojis, :image_file_size],
[:imports, :data_file_size],
[:media_attachments, :file_file_size],
[:media_attachments, :thumbnail_file_size],
[:preview_cards, :image_file_size],
[:site_uploads, :file_file_size],
].freeze

disable_ddl_transaction!

def migrate_columns(to_type)
TABLE_COLUMN_MAPPING.each do |column_parts|
table, column = column_parts

# Skip this if we're resuming and already did this one.
next if column_for(table, column).sql_type == to_type.to_s

safety_assured do
change_column_type_concurrently table, column, to_type
cleanup_concurrent_column_type_change table, column
end
end
end

def up
migrate_columns(:integer)
end

def down
migrate_columns(:integer)
end
end
18 changes: 9 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_04_26_233435) do
ActiveRecord::Schema[7.1].define(version: 2024_05_09_220635) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -204,8 +204,8 @@
t.boolean "indexable", default: false, null: false
t.jsonb "master_settings"
t.boolean "remote_pending", default: false, null: false
t.bigint "avatar_file_size"
t.bigint "header_file_size"
t.integer "avatar_file_size"
t.integer "header_file_size"
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
t.index ["domain", "id"], name: "index_accounts_on_domain_and_id"
Expand Down Expand Up @@ -505,7 +505,7 @@
t.jsonb "aliases"
t.boolean "is_sensitive", default: false, null: false
t.string "license"
t.bigint "image_file_size"
t.integer "image_file_size"
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
end

Expand Down Expand Up @@ -735,7 +735,7 @@
t.datetime "data_updated_at", precision: nil
t.bigint "account_id", null: false
t.boolean "overwrite", default: false, null: false
t.bigint "data_file_size"
t.integer "data_file_size"
end

create_table "instance_infos", force: :cascade do |t|
Expand Down Expand Up @@ -846,8 +846,8 @@
t.string "thumbnail_content_type"
t.datetime "thumbnail_updated_at", precision: nil
t.string "thumbnail_remote_url"
t.bigint "file_file_size"
t.bigint "thumbnail_file_size"
t.integer "file_file_size"
t.integer "thumbnail_file_size"
t.index ["account_id", "status_id"], name: "index_media_attachments_on_account_id_and_status_id", order: { status_id: :desc }
t.index ["id"], name: "index_media_attachments_vacuum", where: "((file_file_name IS NOT NULL) AND ((remote_url)::text <> ''::text))"
t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id", where: "(scheduled_status_id IS NOT NULL)"
Expand Down Expand Up @@ -1174,7 +1174,7 @@
t.integer "link_type"
t.datetime "published_at"
t.string "image_description", default: "", null: false
t.bigint "image_file_size"
t.integer "image_file_size"
t.index ["id"], name: "index_preview_cards_vacuum", where: "((image_file_name IS NOT NULL) AND ((image_file_name)::text <> ''::text))"
t.index ["url"], name: "index_preview_cards_on_url", unique: true
end
Expand Down Expand Up @@ -1317,7 +1317,7 @@
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.string "blurhash"
t.bigint "file_file_size"
t.integer "file_file_size"
t.index ["var"], name: "index_site_uploads_on_var", unique: true
end

Expand Down

0 comments on commit d7c13bf

Please sign in to comment.