diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-04-03 17:21:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 17:21:33 +0200 |
commit | 8192b0da7cd1fac38a68eab6746fc7ec74328a77 (patch) | |
tree | 686c30ed5f6c4cfe5f6b4d84e46ff19f7baa6949 /db | |
parent | cbdb25ab0343603165fc89fd28b07c9ca0f2ae6d (diff) | |
parent | 7b15f4006adb5f8f04d83174532c30eeb78757b0 (diff) |
Merge pull request #2155 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'db')
54 files changed, 226 insertions, 99 deletions
diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb index bf875e4e5..e3fc34a51 100644 --- a/db/migrate/20170918125918_ids_to_bigints.rb +++ b/db/migrate/20170918125918_ids_to_bigints.rb @@ -1,7 +1,9 @@ -require Rails.root.join('lib', 'mastodon', 'migration_helpers') +require_relative '../../lib/mastodon/migration_helpers' +require_relative '../../lib/mastodon/migration_warning' class IdsToBigints < ActiveRecord::Migration[5.1] include Mastodon::MigrationHelpers + include Mastodon::MigrationWarning disable_ddl_transaction! @@ -69,24 +71,12 @@ class IdsToBigints < ActiveRecord::Migration[5.1] ] included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards) - # Print out a warning that this will probably take a while. - if $stdout.isatty - say '' - say 'WARNING: This migration may take a *long* time for large instances' - say 'It will *not* lock tables for any significant time, but it may run' - say 'for a very long time. We will pause for 10 seconds to allow you to' - say 'interrupt this migration if you are not ready.' - say '' - say 'This migration has some sections that can be safely interrupted' - say 'and restarted later, and will tell you when those are occurring.' - say '' - say 'For more information, see https://github.com/mastodon/mastodon/pull/5088' + migration_duration_warning(<<~EXPLANATION) + This migration has some sections that can be safely interrupted + and restarted later, and will tell you when those are occurring. - 10.downto(1) do |i| - say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true - sleep 1 - end - end + For more information, see https://github.com/mastodon/mastodon/pull/5088 + EXPLANATION tables = included_columns.map(&:first).uniq table_sizes = {} diff --git a/db/migrate/20170927215609_add_description_to_media_attachments.rb b/db/migrate/20170927215609_add_description_to_media_attachments.rb index db8d76566..9c3312373 100644 --- a/db/migrate/20170927215609_add_description_to_media_attachments.rb +++ b/db/migrate/20170927215609_add_description_to_media_attachments.rb @@ -1,4 +1,4 @@ -class AddDescriptionToMediaAttachments < ActiveRecord::Migration[5.1] +class AddDescriptionToMediaAttachments < ActiveRecord::Migration[5.2] def change add_column :media_attachments, :description, :text end diff --git a/db/migrate/20170928082043_create_email_domain_blocks.rb b/db/migrate/20170928082043_create_email_domain_blocks.rb index 1f0fb7587..2baed54ef 100644 --- a/db/migrate/20170928082043_create_email_domain_blocks.rb +++ b/db/migrate/20170928082043_create_email_domain_blocks.rb @@ -1,4 +1,4 @@ -class CreateEmailDomainBlocks < ActiveRecord::Migration[5.1] +class CreateEmailDomainBlocks < ActiveRecord::Migration[5.2] def change create_table :email_domain_blocks do |t| t.string :domain, null: false diff --git a/db/migrate/20171005102658_create_account_moderation_notes.rb b/db/migrate/20171005102658_create_account_moderation_notes.rb index 010b94586..afa2f5f25 100644 --- a/db/migrate/20171005102658_create_account_moderation_notes.rb +++ b/db/migrate/20171005102658_create_account_moderation_notes.rb @@ -1,4 +1,4 @@ -class CreateAccountModerationNotes < ActiveRecord::Migration[5.1] +class CreateAccountModerationNotes < ActiveRecord::Migration[5.2] def change create_table :account_moderation_notes do |t| t.text :content, null: false diff --git a/db/migrate/20171005171936_add_disabled_to_custom_emojis.rb b/db/migrate/20171005171936_add_disabled_to_custom_emojis.rb index 067a7bee0..7cf007ae9 100644 --- a/db/migrate/20171005171936_add_disabled_to_custom_emojis.rb +++ b/db/migrate/20171005171936_add_disabled_to_custom_emojis.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddDisabledToCustomEmojis < ActiveRecord::Migration[5.1] +class AddDisabledToCustomEmojis < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171006142024_add_uri_to_custom_emojis.rb b/db/migrate/20171006142024_add_uri_to_custom_emojis.rb index 04dfcf397..ff62aed20 100644 --- a/db/migrate/20171006142024_add_uri_to_custom_emojis.rb +++ b/db/migrate/20171006142024_add_uri_to_custom_emojis.rb @@ -1,4 +1,4 @@ -class AddUriToCustomEmojis < ActiveRecord::Migration[5.1] +class AddUriToCustomEmojis < ActiveRecord::Migration[5.2] def change add_column :custom_emojis, :uri, :string add_column :custom_emojis, :image_remote_url, :string diff --git a/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb b/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb index cdcd15934..a2c0fbcc4 100644 --- a/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb +++ b/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb @@ -1,4 +1,4 @@ -class AddForeignKeyToAccountModerationNotes < ActiveRecord::Migration[5.1] +class AddForeignKeyToAccountModerationNotes < ActiveRecord::Migration[5.2] def change safety_assured { add_foreign_key :account_moderation_notes, :accounts } end diff --git a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb index 1d7a0086c..62725c88d 100644 --- a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb +++ b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb @@ -1,4 +1,4 @@ -class ChangeAccountsNonnullableInAccountModerationNotes < ActiveRecord::Migration[5.1] +class ChangeAccountsNonnullableInAccountModerationNotes < ActiveRecord::Migration[5.2] def change safety_assured do change_column_null :account_moderation_notes, :account_id, false diff --git a/db/migrate/20171020084748_add_visible_in_picker_to_custom_emoji.rb b/db/migrate/20171020084748_add_visible_in_picker_to_custom_emoji.rb index 946e26ff2..5f7c60a3e 100644 --- a/db/migrate/20171020084748_add_visible_in_picker_to_custom_emoji.rb +++ b/db/migrate/20171020084748_add_visible_in_picker_to_custom_emoji.rb @@ -1,4 +1,4 @@ -class AddVisibleInPickerToCustomEmoji < ActiveRecord::Migration[5.1] +class AddVisibleInPickerToCustomEmoji < ActiveRecord::Migration[5.2] def change safety_assured do add_column :custom_emojis, :visible_in_picker, :boolean, default: true, null: false diff --git a/db/migrate/20171028221157_add_reblogs_to_follows.rb b/db/migrate/20171028221157_add_reblogs_to_follows.rb index 3b2e46ed8..773904249 100644 --- a/db/migrate/20171028221157_add_reblogs_to_follows.rb +++ b/db/migrate/20171028221157_add_reblogs_to_follows.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddReblogsToFollows < ActiveRecord::Migration[5.1] +class AddReblogsToFollows < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171107143332_add_memorial_to_accounts.rb b/db/migrate/20171107143332_add_memorial_to_accounts.rb index f3e012ce8..4fb1216a1 100644 --- a/db/migrate/20171107143332_add_memorial_to_accounts.rb +++ b/db/migrate/20171107143332_add_memorial_to_accounts.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddMemorialToAccounts < ActiveRecord::Migration[5.1] +class AddMemorialToAccounts < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171107143624_add_disabled_to_users.rb b/db/migrate/20171107143624_add_disabled_to_users.rb index a71cac1c6..fb736786d 100644 --- a/db/migrate/20171107143624_add_disabled_to_users.rb +++ b/db/migrate/20171107143624_add_disabled_to_users.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddDisabledToUsers < ActiveRecord::Migration[5.1] +class AddDisabledToUsers < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171109012327_add_moderator_to_accounts.rb b/db/migrate/20171109012327_add_moderator_to_accounts.rb index ddd87583a..70b0b598c 100644 --- a/db/migrate/20171109012327_add_moderator_to_accounts.rb +++ b/db/migrate/20171109012327_add_moderator_to_accounts.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddModeratorToAccounts < ActiveRecord::Migration[5.1] +class AddModeratorToAccounts < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171114080328_add_index_domain_to_email_domain_blocks.rb b/db/migrate/20171114080328_add_index_domain_to_email_domain_blocks.rb index 84a341510..34dc6ff00 100644 --- a/db/migrate/20171114080328_add_index_domain_to_email_domain_blocks.rb +++ b/db/migrate/20171114080328_add_index_domain_to_email_domain_blocks.rb @@ -1,4 +1,4 @@ -class AddIndexDomainToEmailDomainBlocks < ActiveRecord::Migration[5.1] +class AddIndexDomainToEmailDomainBlocks < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20171114231651_create_lists.rb b/db/migrate/20171114231651_create_lists.rb index 21285e901..b7761abe4 100644 --- a/db/migrate/20171114231651_create_lists.rb +++ b/db/migrate/20171114231651_create_lists.rb @@ -1,4 +1,4 @@ -class CreateLists < ActiveRecord::Migration[5.1] +class CreateLists < ActiveRecord::Migration[5.2] def change create_table :lists do |t| t.references :account, foreign_key: { on_delete: :cascade } diff --git a/db/migrate/20171116161857_create_list_accounts.rb b/db/migrate/20171116161857_create_list_accounts.rb index b76c90651..7dbb78d8d 100644 --- a/db/migrate/20171116161857_create_list_accounts.rb +++ b/db/migrate/20171116161857_create_list_accounts.rb @@ -1,4 +1,4 @@ -class CreateListAccounts < ActiveRecord::Migration[5.1] +class CreateListAccounts < ActiveRecord::Migration[5.2] def change create_table :list_accounts do |t| t.belongs_to :list, foreign_key: { on_delete: :cascade }, null: false diff --git a/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb index 586ef6f02..893972848 100644 --- a/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb +++ b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb @@ -1,4 +1,4 @@ -class AddMovedToAccountIdToAccounts < ActiveRecord::Migration[5.1] +class AddMovedToAccountIdToAccounts < ActiveRecord::Migration[5.2] def change add_column :accounts, :moved_to_account_id, :bigint, null: true, default: nil safety_assured { add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify } diff --git a/db/migrate/20171119172437_create_admin_action_logs.rb b/db/migrate/20171119172437_create_admin_action_logs.rb index b690735d2..80d5a3dba 100644 --- a/db/migrate/20171119172437_create_admin_action_logs.rb +++ b/db/migrate/20171119172437_create_admin_action_logs.rb @@ -1,4 +1,4 @@ -class CreateAdminActionLogs < ActiveRecord::Migration[5.1] +class CreateAdminActionLogs < ActiveRecord::Migration[5.2] def change create_table :admin_action_logs do |t| t.belongs_to :account, foreign_key: { on_delete: :cascade } diff --git a/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb b/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb index 131e54b72..a02ffe09d 100644 --- a/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb +++ b/db/migrate/20171122120436_add_index_account_and_reblog_of_id_to_statuses.rb @@ -1,4 +1,4 @@ -class AddIndexAccountAndReblogOfIdToStatuses < ActiveRecord::Migration[5.1] +class AddIndexAccountAndReblogOfIdToStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up diff --git a/db/migrate/20171125024930_create_invites.rb b/db/migrate/20171125024930_create_invites.rb index bcf03bd72..2e814babf 100644 --- a/db/migrate/20171125024930_create_invites.rb +++ b/db/migrate/20171125024930_create_invites.rb @@ -1,4 +1,4 @@ -class CreateInvites < ActiveRecord::Migration[5.1] +class CreateInvites < ActiveRecord::Migration[5.2] def change create_table :invites do |t| t.belongs_to :user, foreign_key: { on_delete: :cascade } diff --git a/db/migrate/20171125031751_add_invite_id_to_users.rb b/db/migrate/20171125031751_add_invite_id_to_users.rb index 9cfb0c542..2ff6c3430 100644 --- a/db/migrate/20171125031751_add_invite_id_to_users.rb +++ b/db/migrate/20171125031751_add_invite_id_to_users.rb @@ -1,4 +1,4 @@ -class AddInviteIdToUsers < ActiveRecord::Migration[5.1] +class AddInviteIdToUsers < ActiveRecord::Migration[5.2] def change safety_assured { add_reference :users, :invite, null: true, default: nil, foreign_key: { on_delete: :nullify }, index: false } end diff --git a/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb b/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb index 37662eaa5..8952387b5 100644 --- a/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb +++ b/db/migrate/20171125185353_add_index_reblog_of_id_and_account_to_statuses.rb @@ -1,4 +1,4 @@ -class AddIndexReblogOfIdAndAccountToStatuses < ActiveRecord::Migration[5.1] +class AddIndexReblogOfIdAndAccountToStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb b/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb index 68146c5ce..dc7e09a25 100644 --- a/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb +++ b/db/migrate/20171125190735_remove_old_reblog_index_on_statuses.rb @@ -1,4 +1,4 @@ -class RemoveOldReblogIndexOnStatuses < ActiveRecord::Migration[5.1] +class RemoveOldReblogIndexOnStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up diff --git a/db/migrate/20171129172043_add_index_on_stream_entries.rb b/db/migrate/20171129172043_add_index_on_stream_entries.rb index 181c4f288..4580fb42f 100644 --- a/db/migrate/20171129172043_add_index_on_stream_entries.rb +++ b/db/migrate/20171129172043_add_index_on_stream_entries.rb @@ -1,4 +1,4 @@ -class AddIndexOnStreamEntries < ActiveRecord::Migration[5.1] +class AddIndexOnStreamEntries < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20171130000000_add_embed_url_to_preview_cards.rb b/db/migrate/20171130000000_add_embed_url_to_preview_cards.rb index 8fcabef9f..811f6ceae 100644 --- a/db/migrate/20171130000000_add_embed_url_to_preview_cards.rb +++ b/db/migrate/20171130000000_add_embed_url_to_preview_cards.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.1] +class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb b/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb index ac86c9e77..e8e878611 100644 --- a/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb +++ b/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb @@ -1,4 +1,4 @@ -class ChangeAccountIdNonnullableInLists < ActiveRecord::Migration[5.1] +class ChangeAccountIdNonnullableInLists < ActiveRecord::Migration[5.2] def change safety_assured do change_column_null :lists, :account_id, false diff --git a/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb b/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb index ba67eee86..f3007c77c 100644 --- a/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb +++ b/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb @@ -1,4 +1,4 @@ -class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1] +class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.2] def change remove_index :list_accounts, name: 'index_list_accounts_on_account_id' remove_index :list_accounts, name: 'index_list_accounts_on_list_id' diff --git a/db/migrate/20171226094803_more_faster_index_on_notifications.rb b/db/migrate/20171226094803_more_faster_index_on_notifications.rb index 0273a4e7c..e0e73b27a 100644 --- a/db/migrate/20171226094803_more_faster_index_on_notifications.rb +++ b/db/migrate/20171226094803_more_faster_index_on_notifications.rb @@ -1,4 +1,4 @@ -class MoreFasterIndexOnNotifications < ActiveRecord::Migration[5.1] +class MoreFasterIndexOnNotifications < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index 401fc5e62..eb277d3bc 100644 --- a/db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -1,4 +1,4 @@ -class AddIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.1] +class AddIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20180109143959_add_remember_token_to_users.rb b/db/migrate/20180109143959_add_remember_token_to_users.rb index 662905bcb..f244fc6f6 100644 --- a/db/migrate/20180109143959_add_remember_token_to_users.rb +++ b/db/migrate/20180109143959_add_remember_token_to_users.rb @@ -1,4 +1,4 @@ -class AddRememberTokenToUsers < ActiveRecord::Migration[5.1] +class AddRememberTokenToUsers < ActiveRecord::Migration[5.2] def change add_column :users, :remember_token, :string, null: true end diff --git a/db/migrate/20180204034416_create_identities.rb b/db/migrate/20180204034416_create_identities.rb index f6f5da910..68288aadf 100644 --- a/db/migrate/20180204034416_create_identities.rb +++ b/db/migrate/20180204034416_create_identities.rb @@ -1,7 +1,7 @@ -class CreateIdentities < ActiveRecord::Migration[5.0] +class CreateIdentities < ActiveRecord::Migration[5.2] def change - create_table :identities do |t| - t.references :user, foreign_key: { on_delete: :cascade } + create_table :identities, id: :integer do |t| + t.references :user, type: :integer, foreign_key: { on_delete: :cascade } t.string :provider, null: false, default: '' t.string :uid, null: false, default: '' diff --git a/db/migrate/20180206000000_change_user_id_nonnullable.rb b/db/migrate/20180206000000_change_user_id_nonnullable.rb index 2d2cf20d3..119638387 100644 --- a/db/migrate/20180206000000_change_user_id_nonnullable.rb +++ b/db/migrate/20180206000000_change_user_id_nonnullable.rb @@ -1,4 +1,4 @@ -class ChangeUserIdNonnullable < ActiveRecord::Migration[5.1] +class ChangeUserIdNonnullable < ActiveRecord::Migration[5.2] def change safety_assured do change_column_null :invites, :user_id, false diff --git a/db/migrate/20180211015820_create_backups.rb b/db/migrate/20180211015820_create_backups.rb index 9725a3e9f..4aaeed83b 100644 --- a/db/migrate/20180211015820_create_backups.rb +++ b/db/migrate/20180211015820_create_backups.rb @@ -1,4 +1,4 @@ -class CreateBackups < ActiveRecord::Migration[5.1] +class CreateBackups < ActiveRecord::Migration[5.2] def change create_table :backups do |t| t.references :user, foreign_key: { on_delete: :nullify } diff --git a/db/migrate/20180304013859_add_featured_collection_url_to_accounts.rb b/db/migrate/20180304013859_add_featured_collection_url_to_accounts.rb index 1964b5121..46842a9e3 100644 --- a/db/migrate/20180304013859_add_featured_collection_url_to_accounts.rb +++ b/db/migrate/20180304013859_add_featured_collection_url_to_accounts.rb @@ -1,4 +1,4 @@ -class AddFeaturedCollectionURLToAccounts < ActiveRecord::Migration[5.1] +class AddFeaturedCollectionURLToAccounts < ActiveRecord::Migration[5.2] def change add_column :accounts, :featured_collection_url, :string end diff --git a/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb b/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb index dba789207..8577d0235 100644 --- a/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb +++ b/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb @@ -1,4 +1,4 @@ -class ChangeColumnsInNotificationsNonnullable < ActiveRecord::Migration[5.1] +class ChangeColumnsInNotificationsNonnullable < ActiveRecord::Migration[5.2] def change safety_assured do change_column_null :notifications, :activity_id, false diff --git a/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb b/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb index e2d1371d2..27cbd6c2a 100644 --- a/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb +++ b/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb @@ -1,4 +1,4 @@ -class AddAssignedAccountIdToReports < ActiveRecord::Migration[5.1] +class AddAssignedAccountIdToReports < ActiveRecord::Migration[5.2] def change safety_assured { add_reference :reports, :assigned_account, null: true, default: nil, foreign_key: { on_delete: :nullify, to_table: :accounts }, index: false } end diff --git a/db/migrate/20180402040909_create_report_notes.rb b/db/migrate/20180402040909_create_report_notes.rb index 429cb4534..5d5a33627 100644 --- a/db/migrate/20180402040909_create_report_notes.rb +++ b/db/migrate/20180402040909_create_report_notes.rb @@ -1,4 +1,4 @@ -class CreateReportNotes < ActiveRecord::Migration[5.1] +class CreateReportNotes < ActiveRecord::Migration[5.2] def change create_table :report_notes do |t| t.text :content, null: false diff --git a/db/migrate/20180410204633_add_fields_to_accounts.rb b/db/migrate/20180410204633_add_fields_to_accounts.rb index 5b8c17480..a1b9504b6 100644 --- a/db/migrate/20180410204633_add_fields_to_accounts.rb +++ b/db/migrate/20180410204633_add_fields_to_accounts.rb @@ -1,4 +1,4 @@ -class AddFieldsToAccounts < ActiveRecord::Migration[5.1] +class AddFieldsToAccounts < ActiveRecord::Migration[5.2] def change add_column :accounts, :fields, :jsonb end diff --git a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index a3f883fcb..48d156bef 100644 --- a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.1] +class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change - # These changes ware reverted by migration 20180514140000. + # These changes were reverted by migration 20180514140000. # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index c00302804..242ae7410 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.1] +class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb index 0b39f7107..1e67b4bb4 100644 --- a/db/migrate/20180528141303_fix_accounts_unique_index.rb +++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb @@ -1,4 +1,8 @@ +require_relative '../../lib/mastodon/migration_warning' + class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2] + include Mastodon::MigrationWarning + class Account < ApplicationRecord # Dummy class, to make migration possible across version changes has_one :user, inverse_of: :account @@ -35,22 +39,11 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - if $stdout.isatty - say '' - say 'WARNING: This migration may take a *long* time for large instances' - say 'It will *not* lock tables for any significant time, but it may run' - say 'for a very long time. We will pause for 10 seconds to allow you to' - say 'interrupt this migration if you are not ready.' - say '' - say 'This migration will irreversibly delete user accounts with duplicate' - say 'usernames. You may use the `rake mastodon:maintenance:find_duplicate_usernames`' - say 'task to manually deal with such accounts before running this migration.' - - 10.downto(1) do |i| - say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true - sleep 1 - end - end + migration_duration_warning(<<~EXPLANATION) + This migration will irreversibly delete user accounts with duplicate + usernames. You may use the `rake mastodon:maintenance:find_duplicate_usernames` + task to manually deal with such accounts before running this migration. + EXPLANATION duplicates = Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_ary diff --git a/db/migrate/20180831171112_create_bookmarks.rb b/db/migrate/20180831171112_create_bookmarks.rb index 5d587b7e9..9f6bfae57 100644 --- a/db/migrate/20180831171112_create_bookmarks.rb +++ b/db/migrate/20180831171112_create_bookmarks.rb @@ -1,7 +1,7 @@ # This migration is a duplicate of 20180410220657 and may get ignored, see # config/initializers/0_duplicate_migrations.rb -class CreateBookmarks < ActiveRecord::Migration[5.1] +class CreateBookmarks < ActiveRecord::Migration[5.2] def change create_table :bookmarks do |t| t.references :account, null: false diff --git a/db/migrate/20181024224956_migrate_account_conversations.rb b/db/migrate/20181024224956_migrate_account_conversations.rb index aca6638e1..e4dcdb18b 100644 --- a/db/migrate/20181024224956_migrate_account_conversations.rb +++ b/db/migrate/20181024224956_migrate_account_conversations.rb @@ -1,4 +1,8 @@ +require_relative '../../lib/mastodon/migration_warning' + class MigrateAccountConversations < ActiveRecord::Migration[5.2] + include Mastodon::MigrationWarning + disable_ddl_transaction! class Mention < ApplicationRecord @@ -62,19 +66,7 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2] end def up - if $stdout.isatty - say '' - say 'WARNING: This migration may take a *long* time for large instances' - say 'It will *not* lock tables for any significant time, but it may run' - say 'for a very long time. We will pause for 10 seconds to allow you to' - say 'interrupt this migration if you are not ready.' - say '' - - 10.downto(1) do |i| - say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true - sleep 1 - end - end + migration_duration_warning migrated = 0 last_time = Time.zone.now diff --git a/db/migrate/20191031163205_change_list_account_follow_nullable.rb b/db/migrate/20191031163205_change_list_account_follow_nullable.rb index 65ff93365..43ebfe892 100644 --- a/db/migrate/20191031163205_change_list_account_follow_nullable.rb +++ b/db/migrate/20191031163205_change_list_account_follow_nullable.rb @@ -1,4 +1,4 @@ -class ChangeListAccountFollowNullable < ActiveRecord::Migration[5.1] +class ChangeListAccountFollowNullable < ActiveRecord::Migration[5.2] def change safety_assured do change_column_null :list_accounts, :follow_id, true diff --git a/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb b/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb index ccd65bf53..7c141e7af 100644 --- a/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb +++ b/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb @@ -1,4 +1,4 @@ -class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.1] +class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.2] def up # Set up the media_attachments.id column to use our timestamp-based IDs. safety_assured do diff --git a/db/migrate/20200917192924_add_notify_to_follows.rb b/db/migrate/20200917192924_add_notify_to_follows.rb index d27471c44..342eaa38d 100644 --- a/db/migrate/20200917192924_add_notify_to_follows.rb +++ b/db/migrate/20200917192924_add_notify_to_follows.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'mastodon', 'migration_helpers') -class AddNotifyToFollows < ActiveRecord::Migration[5.1] +class AddNotifyToFollows < ActiveRecord::Migration[5.2] include Mastodon::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb b/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb index 40c582842..b287c60dd 100644 --- a/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb +++ b/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb @@ -1,4 +1,4 @@ -class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1] +class AccountIdsToTimestampIds < ActiveRecord::Migration[5.2] def up # Set up the accounts.id column to use our timestamp-based IDs. safety_assured do diff --git a/db/migrate/20230215074327_add_settings_to_users.rb b/db/migrate/20230215074327_add_settings_to_users.rb new file mode 100644 index 000000000..ff5308f42 --- /dev/null +++ b/db/migrate/20230215074327_add_settings_to_users.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSettingsToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :settings, :text + end +end diff --git a/db/migrate/20230215074423_move_user_settings.rb b/db/migrate/20230215074423_move_user_settings.rb new file mode 100644 index 000000000..351a8b61d --- /dev/null +++ b/db/migrate/20230215074423_move_user_settings.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +class MoveUserSettings < ActiveRecord::Migration[6.1] + class User < ApplicationRecord; end + + MAPPING = { + default_privacy: 'default_privacy', + default_sensitive: 'web.default_sensitive', + default_language: 'default_language', + noindex: 'noindex', + theme: 'theme', + trends: 'web.trends', + unfollow_modal: 'web.unfollow_modal', + boost_modal: 'web.reblog_modal', + delete_modal: 'web.delete_modal', + auto_play_gif: 'web.auto_play', + display_media: 'web.display_media', + expand_spoilers: 'web.expand_content_warnings', + reduce_motion: 'web.reduce_motion', + disable_swiping: 'web.disable_swiping', + show_application: 'show_application', + system_font_ui: 'web.use_system_font', + aggregate_reblogs: 'aggregate_reblogs', + advanced_layout: 'web.advanced_layout', + use_blurhash: 'web.use_blurhash', + use_pending_items: 'web.use_pending_items', + crop_images: 'web.crop_images', + notification_emails: { + follow: 'notification_emails.follow', + reblog: 'notification_emails.reblog', + favourite: 'notification_emails.favourite', + mention: 'notification_emails.mention', + follow_request: 'notification_emails.follow_request', + report: 'notification_emails.report', + pending_account: 'notification_emails.pending_account', + trending_tag: 'notification_emails.trends', + appeal: 'notification_emails.appeal', + }.freeze, + always_send_emails: 'always_send_emails', + interactions: { + must_be_follower: 'interactions.must_be_follower', + must_be_following: 'interactions.must_be_following', + must_be_following_dm: 'interactions.must_be_following_dm', + }.freeze, + }.freeze + + class LegacySetting < ApplicationRecord + self.table_name = 'settings' + + def var + self[:var]&.to_sym + end + + def value + YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) if self[:value].present? + end + end + + def up + User.find_each do |user| + previous_settings = LegacySetting.where(thing_type: 'User', thing_id: user.id).index_by(&:var) + + user_settings = {} + + MAPPING.each do |legacy_key, new_key| + value = previous_settings[legacy_key]&.value + + next if value.blank? + + if value.is_a?(Hash) + value.each do |nested_key, nested_value| + user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value + end + else + user_settings[new_key] = value + end + end + + user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations + end + end + + def down; end +end diff --git a/db/migrate/20230215074424_move_glitch_user_settings.rb b/db/migrate/20230215074424_move_glitch_user_settings.rb new file mode 100644 index 000000000..6b5a25925 --- /dev/null +++ b/db/migrate/20230215074424_move_glitch_user_settings.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +class MoveGlitchUserSettings < ActiveRecord::Migration[6.1] + class User < ApplicationRecord; end + + MAPPING = { + favourite_modal: 'web.favourite_modal', + system_emoji_font: 'web.use_system_emoji_font', + hide_followers_count: 'hide_followers_count', + default_content_type: 'default_content_type', + flavour: 'flavour', + skin: 'skin', + notification_emails: { + trending_link: 'notification_emails.link_trends', + trending_status: 'notification_emails.status_trends', + }.freeze, + }.freeze + + class LegacySetting < ApplicationRecord + self.table_name = 'settings' + + def var + self[:var]&.to_sym + end + + def value + YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) if self[:value].present? + end + end + + def up + User.find_each do |user| + previous_settings = LegacySetting.where(thing_type: 'User', thing_id: user.id).index_by(&:var) + + user_settings = Oj.load(user.settings || '{}') + user_settings.delete('theme') + + MAPPING.each do |legacy_key, new_key| + value = previous_settings[legacy_key]&.value + + next if value.blank? + + if value.is_a?(Hash) + value.each do |nested_key, nested_value| + user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value + end + else + user_settings[new_key] = value + end + end + + user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations + end + end + + def down; end +end diff --git a/db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb b/db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb index a46349cb7..615f35cd0 100644 --- a/db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb +++ b/db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb @@ -34,6 +34,7 @@ class RemoveSuspendedSilencedAccountFields < ActiveRecord::Migration[5.2] remove_column :accounts, :suspended, :boolean, null: false, default: false remove_column :accounts, :silenced, :boolean, null: false, default: false end + Account.reset_column_information end def down diff --git a/db/post_migrate/20210308133107_remove_subscription_expires_at_from_accounts.rb b/db/post_migrate/20210308133107_remove_subscription_expires_at_from_accounts.rb index 53e24ef26..511104cef 100644 --- a/db/post_migrate/20210308133107_remove_subscription_expires_at_from_accounts.rb +++ b/db/post_migrate/20210308133107_remove_subscription_expires_at_from_accounts.rb @@ -1,7 +1,7 @@ -class RemoveSubscriptionExpiresAtFromAccounts < ActiveRecord::Migration[5.0] +class RemoveSubscriptionExpiresAtFromAccounts < ActiveRecord::Migration[5.2] def change safety_assured do - remove_column :accounts, :subscription_expires_at, :datetime, null: true, default: nil + remove_column :accounts, :subscription_expires_at, :datetime, null: true, default: nil, precision: nil end end end diff --git a/db/schema.rb b/db/schema.rb index 7462bf2c7..7d894b1aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_12_06_114142) do +ActiveRecord::Schema.define(version: 2023_02_15_074424) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1063,6 +1063,7 @@ ActiveRecord::Schema.define(version: 2022_12_06_114142) do t.inet "sign_up_ip" t.boolean "skip_sign_in_token" t.bigint "role_id" + t.text "settings" t.index ["account_id"], name: "index_users_on_account_id" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)" diff --git a/db/seeds.rb b/db/seeds.rb index 1ca300de7..c01e83f1d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true -Dir[Rails.root.join('db', 'seeds', '*.rb')].sort.each do |seed| - load seed +Chewy.strategy(:mastodon) do + Dir[Rails.root.join('db', 'seeds', '*.rb')].sort.each do |seed| + load seed + end end |