Merge branch 'instance_only_statuses' of https://github.com/masto-donte-com-br/mastodon into hometown-dev
This commit is contained in:
@ -1,17 +1,19 @@
|
||||
class FixNullBooleans < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_default :domain_blocks, :reject_media, false
|
||||
change_column_null :domain_blocks, :reject_media, false, false
|
||||
safety_assured do
|
||||
change_column_default :domain_blocks, :reject_media, false
|
||||
change_column_null :domain_blocks, :reject_media, false, false
|
||||
|
||||
change_column_default :imports, :approved, false
|
||||
change_column_null :imports, :approved, false, false
|
||||
change_column_default :imports, :approved, false
|
||||
change_column_null :imports, :approved, false, false
|
||||
|
||||
change_column_null :statuses, :sensitive, false, false
|
||||
change_column_null :statuses, :reply, false, false
|
||||
change_column_null :statuses, :sensitive, false, false
|
||||
change_column_null :statuses, :reply, false, false
|
||||
|
||||
change_column_null :users, :admin, false, false
|
||||
change_column_null :users, :admin, false, false
|
||||
|
||||
change_column_default :users, :otp_required_for_login, false
|
||||
change_column_null :users, :otp_required_for_login, false, false
|
||||
change_column_default :users, :otp_required_for_login, false
|
||||
change_column_null :users, :otp_required_for_login, false, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,20 +70,22 @@ 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.
|
||||
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/tootsuite/mastodon/pull/5088'
|
||||
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/tootsuite/mastodon/pull/5088'
|
||||
|
||||
10.downto(1) do |i|
|
||||
say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
|
||||
sleep 1
|
||||
10.downto(1) do |i|
|
||||
say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
|
||||
tables = included_columns.map(&:first).uniq
|
||||
|
@ -1,6 +1,8 @@
|
||||
class ChangeAccountsNonnullableInAccountModerationNotes < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_null :account_moderation_notes, :account_id, false
|
||||
change_column_null :account_moderation_notes, :target_account_id, false
|
||||
safety_assured do
|
||||
change_column_null :account_moderation_notes, :account_id, false
|
||||
change_column_null :account_moderation_notes, :target_account_id, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
class ChangeAccountIdNonnullableInLists < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_null :lists, :account_id, false
|
||||
safety_assured do
|
||||
change_column_null :lists, :account_id, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,8 @@
|
||||
class ChangeUserIdNonnullable < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_null :invites, :user_id, false
|
||||
change_column_null :web_settings, :user_id, false
|
||||
safety_assured do
|
||||
change_column_null :invites, :user_id, false
|
||||
change_column_null :web_settings, :user_id, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,10 @@
|
||||
class ChangeColumnsInNotificationsNonnullable < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_null :notifications, :activity_id, false
|
||||
change_column_null :notifications, :activity_type, false
|
||||
change_column_null :notifications, :account_id, false
|
||||
change_column_null :notifications, :from_account_id, false
|
||||
safety_assured do
|
||||
change_column_null :notifications, :activity_id, false
|
||||
change_column_null :notifications, :activity_type, false
|
||||
change_column_null :notifications, :account_id, false
|
||||
change_column_null :notifications, :from_account_id, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -20,19 +20,21 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
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.'
|
||||
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
|
||||
10.downto(1) do |i|
|
||||
say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
|
||||
duplicates = Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_hash
|
||||
|
17
db/migrate/20180831171112_create_bookmarks.rb
Normal file
17
db/migrate/20180831171112_create_bookmarks.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class CreateBookmarks < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :bookmarks do |t|
|
||||
t.references :account, null: false
|
||||
t.references :status, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
safety_assured do
|
||||
add_foreign_key :bookmarks, :accounts, column: :account_id, on_delete: :cascade
|
||||
add_foreign_key :bookmarks, :statuses, column: :status_id, on_delete: :cascade
|
||||
end
|
||||
|
||||
add_index :bookmarks, [:account_id, :status_id], unique: true
|
||||
end
|
||||
end
|
@ -1,17 +1,79 @@
|
||||
class MigrateAccountConversations < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
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 ''
|
||||
class Mention < ApplicationRecord
|
||||
belongs_to :account, inverse_of: :mentions
|
||||
belongs_to :status, -> { unscope(where: :deleted_at) }
|
||||
|
||||
10.downto(1) do |i|
|
||||
say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
|
||||
sleep 1
|
||||
delegate(
|
||||
:username,
|
||||
:acct,
|
||||
to: :account,
|
||||
prefix: true
|
||||
)
|
||||
end
|
||||
|
||||
class Notification < ApplicationRecord
|
||||
belongs_to :account, optional: true
|
||||
belongs_to :activity, polymorphic: true, optional: true
|
||||
|
||||
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', optional: true
|
||||
belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id', optional: true
|
||||
|
||||
def target_status
|
||||
mention&.status
|
||||
end
|
||||
end
|
||||
|
||||
class AccountConversation < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :conversation
|
||||
belongs_to :last_status, -> { unscope(where: :deleted_at) }, class_name: 'Status'
|
||||
|
||||
before_validation :set_last_status
|
||||
|
||||
class << self
|
||||
def add_status(recipient, status)
|
||||
conversation = find_or_initialize_by(account: recipient, conversation_id: status.conversation_id, participant_account_ids: participants_from_status(recipient, status))
|
||||
|
||||
return conversation if conversation.status_ids.include?(status.id)
|
||||
|
||||
conversation.status_ids << status.id
|
||||
conversation.unread = status.account_id != recipient.id
|
||||
conversation.save
|
||||
conversation
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
retry
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def participants_from_status(recipient, status)
|
||||
((status.active_mentions.pluck(:account_id) + [status.account_id]).uniq - [recipient.id]).sort
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_last_status
|
||||
self.status_ids = status_ids.sort
|
||||
self.last_status_id = status_ids.last
|
||||
end
|
||||
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
|
||||
|
||||
migrated = 0
|
||||
|
@ -0,0 +1,7 @@
|
||||
class ChangeListAccountFollowNullable < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_column_null :list_accounts, :follow_id, true
|
||||
end
|
||||
end
|
||||
end
|
21
db/migrate/20191212003415_increase_backup_size.rb
Normal file
21
db/migrate/20191212003415_increase_backup_size.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class IncreaseBackupSize < ActiveRecord::Migration[5.2]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
change_column_type_concurrently :backups, :dump_file_size, :bigint
|
||||
cleanup_concurrent_column_type_change :backups, :dump_file_size
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_column_type_concurrently :backups, :dump_file_size, :integer
|
||||
cleanup_concurrent_column_type_change :backups, :dump_file_size
|
||||
end
|
||||
end
|
||||
end
|
16
db/migrate/20191218153258_create_announcements.rb
Normal file
16
db/migrate/20191218153258_create_announcements.rb
Normal file
@ -0,0 +1,16 @@
|
||||
class CreateAnnouncements < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :announcements do |t|
|
||||
t.text :text, null: false, default: ''
|
||||
|
||||
t.boolean :published, null: false, default: false
|
||||
t.boolean :all_day, null: false, default: false
|
||||
|
||||
t.datetime :scheduled_at
|
||||
t.datetime :starts_at
|
||||
t.datetime :ends_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
12
db/migrate/20200113125135_create_announcement_mutes.rb
Normal file
12
db/migrate/20200113125135_create_announcement_mutes.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateAnnouncementMutes < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :announcement_mutes do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade, index: false }
|
||||
t.belongs_to :announcement, foreign_key: { on_delete: :cascade }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :announcement_mutes, [:account_id, :announcement_id], unique: true
|
||||
end
|
||||
end
|
15
db/migrate/20200114113335_create_announcement_reactions.rb
Normal file
15
db/migrate/20200114113335_create_announcement_reactions.rb
Normal file
@ -0,0 +1,15 @@
|
||||
class CreateAnnouncementReactions < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :announcement_reactions do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade, index: false }
|
||||
t.belongs_to :announcement, foreign_key: { on_delete: :cascade }
|
||||
|
||||
t.string :name, null: false, default: ''
|
||||
t.belongs_to :custom_emoji, foreign_key: { on_delete: :cascade }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :announcement_reactions, [:account_id, :announcement_id, :name], unique: true, name: :index_announcement_reactions_on_account_id_and_announcement_id
|
||||
end
|
||||
end
|
11
db/migrate/20200119112504_add_public_index_to_statuses.rb
Normal file
11
db/migrate/20200119112504_add_public_index_to_statuses.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class AddPublicIndexToStatuses < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_public_20200119, algorithm: :concurrently, order: { id: :desc }, where: 'deleted_at IS NULL AND visibility = 0 AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :statuses, name: :index_statuses_public_20200119
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddPublishedAtToAnnouncements < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :announcements, :published_at, :datetime
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user