Merge tag 'v2.6.0rc1' into instance_only_statuses
This commit is contained in:
@ -34,12 +34,12 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
|
||||
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
||||
#
|
||||
# t.text :token, null: false
|
||||
t.string :token, null: false
|
||||
t.string :token, null: false
|
||||
|
||||
t.string :refresh_token
|
||||
t.integer :expires_in
|
||||
t.datetime :revoked_at
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :created_at, null: false
|
||||
t.string :scopes
|
||||
end
|
||||
|
||||
|
@ -4,4 +4,4 @@ class AddOwnerToApplication < ActiveRecord::Migration[4.2]
|
||||
add_column :oauth_applications, :owner_type, :string, null: true
|
||||
add_index :oauth_applications, [:owner_id, :owner_type]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ end
|
||||
class RailsSettingsMigration < MIGRATION_BASE_CLASS
|
||||
def self.up
|
||||
create_table :settings do |t|
|
||||
t.string :var, :null => false
|
||||
t.string :var, :null => false
|
||||
t.text :value
|
||||
t.references :target, :null => false, :polymorphic => true
|
||||
t.timestamps :null => true
|
||||
|
@ -8,7 +8,7 @@ class AddShortcodeToMediaAttachments < ActiveRecord::Migration[5.0]
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :media_attachments, :shortcode
|
||||
remove_column :media_attachments, :shortcode
|
||||
remove_index :media_attachments, :shortcode
|
||||
remove_column :media_attachments, :shortcode
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
class ChangeTagSearchIndexToBtree < ActiveRecord::Migration[5.1]
|
||||
|
||||
def up
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags (name text_pattern_ops);'
|
||||
|
@ -8,7 +8,7 @@ class AddHideNotificationsToMute < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
add_column_with_default :mutes, :hide_notifications, :boolean, default: true, allow_null: false
|
||||
end
|
||||
|
||||
|
||||
def down
|
||||
remove_column :mutes, :hide_notifications
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ class FixReblogsInFeeds < ActiveRecord::Migration[5.1]
|
||||
|
||||
-- So, first, we iterate over the user's feed to find any reblogs.
|
||||
local items = redis.call('zrange', timeline_key, 0, -1, 'withscores')
|
||||
|
||||
|
||||
for i = 1, #items, 2 do
|
||||
local reblogged_id = items[i]
|
||||
local reblogging_id = items[i + 1]
|
||||
|
@ -11,7 +11,7 @@ class AddReblogsToFollows < ActiveRecord::Migration[5.1]
|
||||
add_column_with_default :follow_requests, :show_reblogs, :boolean, default: true, allow_null: false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def down
|
||||
remove_column :follows, :show_reblogs
|
||||
remove_column :follow_requests, :show_reblogs
|
||||
|
@ -3,15 +3,10 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
||||
execute <<-SQL.squish
|
||||
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
||||
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
||||
FROM statuses
|
||||
WHERE id IN (#{statuses.map(&:id).join(', ')})
|
||||
ON CONFLICT (status_id) DO UPDATE
|
||||
SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
||||
SQL
|
||||
if supports_upsert?
|
||||
up_fast
|
||||
else
|
||||
up_slow
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -19,4 +14,41 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
||||
def down
|
||||
# Nothing
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def supports_upsert?
|
||||
version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
|
||||
version >= 90500
|
||||
end
|
||||
|
||||
def up_fast
|
||||
say 'Upsert is available, importing counters using the fast method'
|
||||
|
||||
Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
||||
execute <<-SQL.squish
|
||||
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
||||
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
||||
FROM statuses
|
||||
WHERE id IN (#{statuses.map(&:id).join(', ')})
|
||||
ON CONFLICT (status_id) DO UPDATE
|
||||
SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def up_slow
|
||||
say 'Upsert is not available in PostgreSQL below 9.5, falling back to slow import of counters'
|
||||
|
||||
# We cannot use bulk INSERT or overarching transactions here because of possible
|
||||
# uniqueness violations that we need to skip over
|
||||
Status.unscoped.select('id, reblogs_count, favourites_count, created_at, updated_at').find_each do |status|
|
||||
begin
|
||||
params = [[nil, status.id], [nil, status.reblogs_count], [nil, status.favourites_count], [nil, status.created_at], [nil, status.updated_at]]
|
||||
exec_insert('INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5)', nil, params)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
14
db/migrate/20180929222014_create_account_conversations.rb
Normal file
14
db/migrate/20180929222014_create_account_conversations.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateAccountConversations < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :account_conversations do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :conversation, foreign_key: { on_delete: :cascade }
|
||||
t.bigint :participant_account_ids, array: true, null: false, default: []
|
||||
t.bigint :status_ids, array: true, null: false, default: []
|
||||
t.bigint :last_status_id, null: true, default: nil
|
||||
t.integer :lock_version, null: false, default: 0
|
||||
end
|
||||
|
||||
add_index :account_conversations, [:account_id, :conversation_id, :participant_account_ids], unique: true, name: 'index_unique_conversations'
|
||||
end
|
||||
end
|
13
db/migrate/20181007025445_create_pghero_space_stats.rb
Normal file
13
db/migrate/20181007025445_create_pghero_space_stats.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class CreatePgheroSpaceStats < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :pghero_space_stats do |t|
|
||||
t.text :database
|
||||
t.text :schema
|
||||
t.text :relation
|
||||
t.integer :size, limit: 8
|
||||
t.timestamp :captured_at
|
||||
end
|
||||
|
||||
add_index :pghero_space_stats, [:database, :captured_at]
|
||||
end
|
||||
end
|
23
db/migrate/20181010141500_add_silent_to_mentions.rb
Normal file
23
db/migrate/20181010141500_add_silent_to_mentions.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddSilentToMentions < ActiveRecord::Migration[5.2]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column_with_default(
|
||||
:mentions,
|
||||
:silent,
|
||||
:boolean,
|
||||
allow_null: false,
|
||||
default: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :mentions, :silent
|
||||
end
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddRejectReportsToDomainBlocks < ActiveRecord::Migration[5.2]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column_with_default :domain_blocks, :reject_reports, :boolean, default: false, allow_null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :domain_blocks, :reject_reports
|
||||
end
|
||||
end
|
@ -0,0 +1,23 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddUnreadToAccountConversations < ActiveRecord::Migration[5.2]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column_with_default(
|
||||
:account_conversations,
|
||||
:unread,
|
||||
:boolean,
|
||||
allow_null: false,
|
||||
default: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :account_conversations, :unread, :boolean
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user