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
|
28
db/schema.rb
28
db/schema.rb
@ -10,11 +10,24 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||
ActiveRecord::Schema.define(version: 2018_10_18_205649) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "account_conversations", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "conversation_id"
|
||||
t.bigint "participant_account_ids", default: [], null: false, array: true
|
||||
t.bigint "status_ids", default: [], null: false, array: true
|
||||
t.bigint "last_status_id"
|
||||
t.integer "lock_version", default: 0, null: false
|
||||
t.boolean "unread", default: false, null: false
|
||||
t.index ["account_id", "conversation_id", "participant_account_ids"], name: "index_unique_conversations", unique: true
|
||||
t.index ["account_id"], name: "index_account_conversations_on_account_id"
|
||||
t.index ["conversation_id"], name: "index_account_conversations_on_conversation_id"
|
||||
end
|
||||
|
||||
create_table "account_domain_blocks", force: :cascade do |t|
|
||||
t.string "domain"
|
||||
t.datetime "created_at", null: false
|
||||
@ -173,6 +186,7 @@ ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "severity", default: 0
|
||||
t.boolean "reject_media", default: false, null: false
|
||||
t.boolean "reject_reports", default: false, null: false
|
||||
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
||||
end
|
||||
|
||||
@ -289,6 +303,7 @@ ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id"
|
||||
t.boolean "silent", default: false, null: false
|
||||
t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
|
||||
t.index ["status_id"], name: "index_mentions_on_status_id"
|
||||
end
|
||||
@ -360,6 +375,15 @@ ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
||||
end
|
||||
|
||||
create_table "pghero_space_stats", force: :cascade do |t|
|
||||
t.text "database"
|
||||
t.text "schema"
|
||||
t.text "relation"
|
||||
t.bigint "size"
|
||||
t.datetime "captured_at"
|
||||
t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
|
||||
end
|
||||
|
||||
create_table "preview_cards", force: :cascade do |t|
|
||||
t.string "url", default: "", null: false
|
||||
t.string "title", default: "", null: false
|
||||
@ -599,6 +623,8 @@ ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||
t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "account_conversations", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_conversations", "conversations", on_delete: :cascade
|
||||
add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
|
||||
add_foreign_key "account_moderation_notes", "accounts"
|
||||
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
|
||||
|
Reference in New Issue
Block a user