Merge upstream 2.0ish #165
This commit is contained in:
@@ -1,127 +1,119 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INCLUDED_COLUMNS = [
|
||||
[:account_domain_blocks, :account_id],
|
||||
[:account_domain_blocks, :id],
|
||||
[:accounts, :id],
|
||||
[:blocks, :account_id],
|
||||
[:blocks, :id],
|
||||
[:blocks, :target_account_id],
|
||||
[:conversation_mutes, :account_id],
|
||||
[:conversation_mutes, :id],
|
||||
[:domain_blocks, :id],
|
||||
[:favourites, :account_id],
|
||||
[:favourites, :id],
|
||||
[:favourites, :status_id],
|
||||
[:follow_requests, :account_id],
|
||||
[:follow_requests, :id],
|
||||
[:follow_requests, :target_account_id],
|
||||
[:follows, :account_id],
|
||||
[:follows, :id],
|
||||
[:follows, :target_account_id],
|
||||
[:imports, :account_id],
|
||||
[:imports, :id],
|
||||
[:media_attachments, :account_id],
|
||||
[:media_attachments, :id],
|
||||
[:mentions, :account_id],
|
||||
[:mentions, :id],
|
||||
[:mutes, :account_id],
|
||||
[:mutes, :id],
|
||||
[:mutes, :target_account_id],
|
||||
[:notifications, :account_id],
|
||||
[:notifications, :from_account_id],
|
||||
[:notifications, :id],
|
||||
[:oauth_access_grants, :application_id],
|
||||
[:oauth_access_grants, :id],
|
||||
[:oauth_access_grants, :resource_owner_id],
|
||||
[:oauth_access_tokens, :application_id],
|
||||
[:oauth_access_tokens, :id],
|
||||
[:oauth_access_tokens, :resource_owner_id],
|
||||
[:oauth_applications, :id],
|
||||
[:oauth_applications, :owner_id],
|
||||
[:reports, :account_id],
|
||||
[:reports, :action_taken_by_account_id],
|
||||
[:reports, :id],
|
||||
[:reports, :target_account_id],
|
||||
[:session_activations, :access_token_id],
|
||||
[:session_activations, :user_id],
|
||||
[:session_activations, :web_push_subscription_id],
|
||||
[:settings, :id],
|
||||
[:settings, :thing_id],
|
||||
[:statuses, :account_id],
|
||||
[:statuses, :application_id],
|
||||
[:statuses, :in_reply_to_account_id],
|
||||
[:stream_entries, :account_id],
|
||||
[:stream_entries, :id],
|
||||
[:subscriptions, :account_id],
|
||||
[:subscriptions, :id],
|
||||
[:tags, :id],
|
||||
[:users, :account_id],
|
||||
[:users, :id],
|
||||
[:web_settings, :id],
|
||||
[:web_settings, :user_id],
|
||||
]
|
||||
INCLUDED_COLUMNS << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||
|
||||
def migrate_columns(to_type)
|
||||
# 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'
|
||||
|
||||
10.downto(1) do |i|
|
||||
say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
|
||||
sleep 1
|
||||
end
|
||||
|
||||
tables = INCLUDED_COLUMNS.map(&:first).uniq
|
||||
table_sizes = {}
|
||||
|
||||
# Sort tables by their size
|
||||
tables.each do |table|
|
||||
table_sizes[table] = estimate_rows_in_table(table)
|
||||
end
|
||||
|
||||
ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts|
|
||||
[-table_sizes[col_parts.first], col_parts.last]
|
||||
end
|
||||
|
||||
ordered_columns.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
|
||||
|
||||
change_column_type_concurrently table, column, to_type
|
||||
cleanup_concurrent_column_type_change table, column
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
change_column :account_domain_blocks, :account_id, :bigint
|
||||
change_column :account_domain_blocks, :id, :bigint
|
||||
change_column :accounts, :id, :bigint
|
||||
change_column :blocks, :account_id, :bigint
|
||||
change_column :blocks, :id, :bigint
|
||||
change_column :blocks, :target_account_id, :bigint
|
||||
change_column :conversation_mutes, :account_id, :bigint
|
||||
change_column :conversation_mutes, :id, :bigint
|
||||
change_column :deprecated_preview_cards, :id, :bigint if table_exists?(:deprecated_preview_cards)
|
||||
change_column :domain_blocks, :id, :bigint
|
||||
change_column :favourites, :account_id, :bigint
|
||||
change_column :favourites, :id, :bigint
|
||||
change_column :favourites, :status_id, :bigint
|
||||
change_column :follow_requests, :account_id, :bigint
|
||||
change_column :follow_requests, :id, :bigint
|
||||
change_column :follow_requests, :target_account_id, :bigint
|
||||
change_column :follows, :account_id, :bigint
|
||||
change_column :follows, :id, :bigint
|
||||
change_column :follows, :target_account_id, :bigint
|
||||
change_column :imports, :account_id, :bigint
|
||||
change_column :imports, :id, :bigint
|
||||
change_column :media_attachments, :account_id, :bigint
|
||||
change_column :media_attachments, :id, :bigint
|
||||
change_column :mentions, :account_id, :bigint
|
||||
change_column :mentions, :id, :bigint
|
||||
change_column :mutes, :account_id, :bigint
|
||||
change_column :mutes, :id, :bigint
|
||||
change_column :mutes, :target_account_id, :bigint
|
||||
change_column :notifications, :account_id, :bigint
|
||||
change_column :notifications, :from_account_id, :bigint
|
||||
change_column :notifications, :id, :bigint
|
||||
change_column :oauth_access_grants, :application_id, :bigint
|
||||
change_column :oauth_access_grants, :id, :bigint
|
||||
change_column :oauth_access_grants, :resource_owner_id, :bigint
|
||||
change_column :oauth_access_tokens, :application_id, :bigint
|
||||
change_column :oauth_access_tokens, :id, :bigint
|
||||
change_column :oauth_access_tokens, :resource_owner_id, :bigint
|
||||
change_column :oauth_applications, :id, :bigint
|
||||
change_column :oauth_applications, :owner_id, :bigint
|
||||
change_column :reports, :account_id, :bigint
|
||||
change_column :reports, :action_taken_by_account_id, :bigint
|
||||
change_column :reports, :id, :bigint
|
||||
change_column :reports, :target_account_id, :bigint
|
||||
change_column :session_activations, :access_token_id, :bigint
|
||||
change_column :session_activations, :user_id, :bigint
|
||||
change_column :session_activations, :web_push_subscription_id, :bigint
|
||||
change_column :settings, :id, :bigint
|
||||
change_column :settings, :thing_id, :bigint
|
||||
change_column :statuses, :account_id, :bigint
|
||||
change_column :statuses, :application_id, :bigint
|
||||
change_column :statuses, :in_reply_to_account_id, :bigint
|
||||
change_column :stream_entries, :account_id, :bigint
|
||||
change_column :stream_entries, :id, :bigint
|
||||
change_column :subscriptions, :account_id, :bigint
|
||||
change_column :subscriptions, :id, :bigint
|
||||
change_column :tags, :id, :bigint
|
||||
change_column :users, :account_id, :bigint
|
||||
change_column :users, :id, :bigint
|
||||
change_column :web_settings, :id, :bigint
|
||||
change_column :web_settings, :user_id, :bigint
|
||||
migrate_columns(:bigint)
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :account_domain_blocks, :account_id, :integer
|
||||
change_column :account_domain_blocks, :id, :integer
|
||||
change_column :accounts, :id, :integer
|
||||
change_column :blocks, :account_id, :integer
|
||||
change_column :blocks, :id, :integer
|
||||
change_column :blocks, :target_account_id, :integer
|
||||
change_column :conversation_mutes, :account_id, :integer
|
||||
change_column :conversation_mutes, :id, :integer
|
||||
change_column :deprecated_preview_cards, :id, :integer if table_exists?(:deprecated_preview_cards)
|
||||
change_column :domain_blocks, :id, :integer
|
||||
change_column :favourites, :account_id, :integer
|
||||
change_column :favourites, :id, :integer
|
||||
change_column :favourites, :status_id, :integer
|
||||
change_column :follow_requests, :account_id, :integer
|
||||
change_column :follow_requests, :id, :integer
|
||||
change_column :follow_requests, :target_account_id, :integer
|
||||
change_column :follows, :account_id, :integer
|
||||
change_column :follows, :id, :integer
|
||||
change_column :follows, :target_account_id, :integer
|
||||
change_column :imports, :account_id, :integer
|
||||
change_column :imports, :id, :integer
|
||||
change_column :media_attachments, :account_id, :integer
|
||||
change_column :media_attachments, :id, :integer
|
||||
change_column :mentions, :account_id, :integer
|
||||
change_column :mentions, :id, :integer
|
||||
change_column :mutes, :account_id, :integer
|
||||
change_column :mutes, :id, :integer
|
||||
change_column :mutes, :target_account_id, :integer
|
||||
change_column :notifications, :account_id, :integer
|
||||
change_column :notifications, :from_account_id, :integer
|
||||
change_column :notifications, :id, :integer
|
||||
change_column :oauth_access_grants, :application_id, :integer
|
||||
change_column :oauth_access_grants, :id, :integer
|
||||
change_column :oauth_access_grants, :resource_owner_id, :integer
|
||||
change_column :oauth_access_tokens, :application_id, :integer
|
||||
change_column :oauth_access_tokens, :id, :integer
|
||||
change_column :oauth_access_tokens, :resource_owner_id, :integer
|
||||
change_column :oauth_applications, :id, :integer
|
||||
change_column :oauth_applications, :owner_id, :integer
|
||||
change_column :reports, :account_id, :integer
|
||||
change_column :reports, :action_taken_by_account_id, :integer
|
||||
change_column :reports, :id, :integer
|
||||
change_column :reports, :target_account_id, :integer
|
||||
change_column :session_activations, :access_token_id, :integer
|
||||
change_column :session_activations, :user_id, :integer
|
||||
change_column :session_activations, :web_push_subscription_id, :integer
|
||||
change_column :settings, :id, :integer
|
||||
change_column :settings, :thing_id, :integer
|
||||
change_column :statuses, :account_id, :integer
|
||||
change_column :statuses, :application_id, :integer
|
||||
change_column :statuses, :in_reply_to_account_id, :integer
|
||||
change_column :stream_entries, :account_id, :integer
|
||||
change_column :stream_entries, :id, :integer
|
||||
change_column :subscriptions, :account_id, :integer
|
||||
change_column :subscriptions, :id, :integer
|
||||
change_column :tags, :id, :integer
|
||||
change_column :users, :account_id, :integer
|
||||
change_column :users, :id, :integer
|
||||
change_column :web_settings, :id, :integer
|
||||
change_column :web_settings, :user_id, :integer
|
||||
migrate_columns(:integer)
|
||||
end
|
||||
end
|
||||
|
||||
32
db/migrate/20170920024819_status_ids_to_timestamp_ids.rb
Normal file
32
db/migrate/20170920024819_status_ids_to_timestamp_ids.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class StatusIdsToTimestampIds < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
# Prepare the function we will use to generate IDs.
|
||||
Rake::Task['db:define_timestamp_id'].execute
|
||||
|
||||
# Set up the statuses.id column to use our timestamp-based IDs.
|
||||
ActiveRecord::Base.connection.execute(<<~SQL)
|
||||
ALTER TABLE statuses
|
||||
ALTER COLUMN id
|
||||
SET DEFAULT timestamp_id('statuses')
|
||||
SQL
|
||||
|
||||
# Make sure we have a sequence to use.
|
||||
Rake::Task['db:ensure_id_sequences_exist'].execute
|
||||
end
|
||||
|
||||
def down
|
||||
# Revert the column to the old method of just using the sequence
|
||||
# value for new IDs. Set the current ID sequence to the maximum
|
||||
# existing ID, such that the next sequence will be one higher.
|
||||
|
||||
# We lock the table during this so that the ID won't get clobbered,
|
||||
# but ID is indexed, so this should be a fast operation.
|
||||
ActiveRecord::Base.connection.execute(<<~SQL)
|
||||
LOCK statuses;
|
||||
SELECT setval('statuses_id_seq', (SELECT MAX(id) FROM statuses));
|
||||
ALTER TABLE statuses
|
||||
ALTER COLUMN id
|
||||
SET DEFAULT nextval('statuses_id_seq');"
|
||||
SQL
|
||||
end
|
||||
end
|
||||
63
db/migrate/20170920032311_fix_reblogs_in_feeds.rb
Normal file
63
db/migrate/20170920032311_fix_reblogs_in_feeds.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
class FixReblogsInFeeds < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
redis = Redis.current
|
||||
fm = FeedManager.instance
|
||||
|
||||
# find_each is batched on the database side.
|
||||
User.includes(:account).find_each do |user|
|
||||
account = user.account
|
||||
|
||||
# Old scheme:
|
||||
# Each user's feed zset had a series of score:value entries,
|
||||
# where "regular" statuses had the same score and value (their
|
||||
# ID). Reblogs had a score of the reblogging status' ID, and a
|
||||
# value of the reblogged status' ID.
|
||||
|
||||
# New scheme:
|
||||
# The feed contains only entries with the same score and value.
|
||||
# Reblogs result in the reblogging status being added to the
|
||||
# feed, with an entry in a reblog tracking zset (where the score
|
||||
# is once again set to the reblogging status' ID, and the value
|
||||
# is set to the reblogged status' ID). This is safe for Redis'
|
||||
# float coersion because in this reblog tracking zset, we only
|
||||
# need the rebloggging status' ID to be able to stop tracking
|
||||
# entries after they have gotten too far down the feed, which
|
||||
# does not require an exact value.
|
||||
|
||||
# So, first, we iterate over the user's feed to find any reblogs.
|
||||
timeline_key = fm.key(:home, account.id)
|
||||
reblog_key = fm.key(:home, account.id, 'reblogs')
|
||||
redis.zrange(timeline_key, 0, -1, with_scores: true).each do |entry|
|
||||
next if entry[0] == entry[1]
|
||||
|
||||
# The score and value don't match, so this is a reblog.
|
||||
# (note that we're transitioning from IDs < 53 bits so we
|
||||
# don't have to worry about the loss of precision)
|
||||
|
||||
reblogged_id, reblogging_id = entry
|
||||
|
||||
# Remove the old entry
|
||||
redis.zrem(timeline_key, reblogged_id)
|
||||
|
||||
# Add a new one for the reblogging status
|
||||
redis.zadd(timeline_key, reblogging_id, reblogging_id)
|
||||
|
||||
# Track the fact that this was a reblog
|
||||
redis.zadd(reblog_key, reblogging_id, reblogged_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
# We *deliberately* do nothing here. This means that reverting
|
||||
# this and the associated changes to the FeedManager code could
|
||||
# allow one superfluous reblog of any given status, but in the case
|
||||
# where things have gone wrong and a revert is necessary, this
|
||||
# appears preferable to requiring a database hit for every status
|
||||
# in every users' feed simply to revert.
|
||||
|
||||
# Note that this is operating under the assumption that entries
|
||||
# with >53-bit IDs have already been entered. Otherwise, we could
|
||||
# just use the data in Redis to reverse this transition.
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddDescriptionToMediaAttachments < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :media_attachments, :description, :text
|
||||
end
|
||||
end
|
||||
9
db/migrate/20170928082043_create_email_domain_blocks.rb
Normal file
9
db/migrate/20170928082043_create_email_domain_blocks.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class CreateEmailDomainBlocks < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :email_domain_blocks do |t|
|
||||
t.string :domain, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
12
db/migrate/20171005102658_create_account_moderation_notes.rb
Normal file
12
db/migrate/20171005102658_create_account_moderation_notes.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateAccountModerationNotes < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :account_moderation_notes do |t|
|
||||
t.text :content, null: false
|
||||
t.references :account
|
||||
t.references :target_account
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_foreign_key :account_moderation_notes, :accounts, column: :target_account_id
|
||||
end
|
||||
end
|
||||
15
db/migrate/20171005171936_add_disabled_to_custom_emojis.rb
Normal file
15
db/migrate/20171005171936_add_disabled_to_custom_emojis.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddDisabledToCustomEmojis < ActiveRecord::Migration[5.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured { add_column_with_default :custom_emojis, :disabled, :bool, default: false }
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :custom_emojis, :disabled
|
||||
end
|
||||
end
|
||||
6
db/migrate/20171006142024_add_uri_to_custom_emojis.rb
Normal file
6
db/migrate/20171006142024_add_uri_to_custom_emojis.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddUriToCustomEmojis < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :custom_emojis, :uri, :string
|
||||
add_column :custom_emojis, :image_remote_url, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddForeignKeyToAccountModerationNotes < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_foreign_key :account_moderation_notes, :accounts
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
end
|
||||
end
|
||||
162
db/schema.rb
162
db/schema.rb
@@ -10,19 +10,29 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
ActiveRecord::Schema.define(version: 20171010025614) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "account_domain_blocks", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.string "domain"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id"
|
||||
t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
|
||||
end
|
||||
|
||||
create_table "account_moderation_notes", force: :cascade do |t|
|
||||
t.text "content", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_account_moderation_notes_on_account_id"
|
||||
t.index ["target_account_id"], name: "index_account_moderation_notes_on_target_account_id"
|
||||
end
|
||||
|
||||
create_table "accounts", force: :cascade do |t|
|
||||
t.string "username", default: "", null: false
|
||||
t.string "domain"
|
||||
@@ -69,16 +79,16 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
end
|
||||
|
||||
create_table "blocks", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
|
||||
end
|
||||
|
||||
create_table "conversation_mutes", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "conversation_id", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
|
||||
end
|
||||
|
||||
@@ -98,6 +108,9 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.datetime "image_updated_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "disabled", default: false, null: false
|
||||
t.string "uri"
|
||||
t.string "image_remote_url"
|
||||
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
|
||||
end
|
||||
|
||||
@@ -110,34 +123,39 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
||||
end
|
||||
|
||||
create_table "favourites", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "status_id", null: false
|
||||
create_table "email_domain_blocks", force: :cascade do |t|
|
||||
t.string "domain", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "favourites", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "status_id", null: false
|
||||
t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
|
||||
t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
|
||||
t.index ["status_id"], name: "index_favourites_on_status_id"
|
||||
end
|
||||
|
||||
create_table "follow_requests", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
|
||||
end
|
||||
|
||||
create_table "follows", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
|
||||
end
|
||||
|
||||
create_table "imports", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.integer "type", null: false
|
||||
t.boolean "approved", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -146,6 +164,7 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.string "data_content_type"
|
||||
t.integer "data_file_size"
|
||||
t.datetime "data_updated_at"
|
||||
t.bigint "account_id", null: false
|
||||
end
|
||||
|
||||
create_table "media_attachments", force: :cascade do |t|
|
||||
@@ -155,41 +174,42 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.integer "file_file_size"
|
||||
t.datetime "file_updated_at"
|
||||
t.string "remote_url", default: "", null: false
|
||||
t.bigint "account_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "shortcode"
|
||||
t.integer "type", default: 0, null: false
|
||||
t.json "file_meta"
|
||||
t.bigint "account_id"
|
||||
t.text "description"
|
||||
t.index ["account_id"], name: "index_media_attachments_on_account_id"
|
||||
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
|
||||
t.index ["status_id"], name: "index_media_attachments_on_status_id"
|
||||
end
|
||||
|
||||
create_table "mentions", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "status_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id"
|
||||
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
|
||||
|
||||
create_table "mutes", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "hide_notifications", default: true, null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
|
||||
end
|
||||
|
||||
create_table "notifications", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "activity_id"
|
||||
t.string "activity_type"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id"
|
||||
t.bigint "from_account_id"
|
||||
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
|
||||
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
|
||||
@@ -197,26 +217,26 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
end
|
||||
|
||||
create_table "oauth_access_grants", force: :cascade do |t|
|
||||
t.bigint "resource_owner_id", null: false
|
||||
t.bigint "application_id", null: false
|
||||
t.string "token", null: false
|
||||
t.integer "expires_in", null: false
|
||||
t.text "redirect_uri", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "revoked_at"
|
||||
t.string "scopes"
|
||||
t.bigint "application_id", null: false
|
||||
t.bigint "resource_owner_id", null: false
|
||||
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
||||
end
|
||||
|
||||
create_table "oauth_access_tokens", force: :cascade do |t|
|
||||
t.bigint "resource_owner_id"
|
||||
t.bigint "application_id"
|
||||
t.string "token", null: false
|
||||
t.string "refresh_token"
|
||||
t.integer "expires_in"
|
||||
t.datetime "revoked_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.string "scopes"
|
||||
t.bigint "application_id"
|
||||
t.bigint "resource_owner_id"
|
||||
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
||||
t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
|
||||
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
||||
@@ -232,8 +252,8 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.datetime "updated_at"
|
||||
t.boolean "superapp", default: false, null: false
|
||||
t.string "website"
|
||||
t.bigint "owner_id"
|
||||
t.string "owner_type"
|
||||
t.bigint "owner_id"
|
||||
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
|
||||
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
||||
end
|
||||
@@ -266,26 +286,26 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
end
|
||||
|
||||
create_table "reports", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "target_account_id", null: false
|
||||
t.bigint "status_ids", default: [], null: false, array: true
|
||||
t.text "comment", default: "", null: false
|
||||
t.boolean "action_taken", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "action_taken_by_account_id"
|
||||
t.bigint "target_account_id", null: false
|
||||
t.index ["account_id"], name: "index_reports_on_account_id"
|
||||
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
|
||||
end
|
||||
|
||||
create_table "session_activations", force: :cascade do |t|
|
||||
t.bigint "user_id", null: false
|
||||
t.string "session_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "user_agent", default: "", null: false
|
||||
t.inet "ip"
|
||||
t.bigint "access_token_id"
|
||||
t.bigint "user_id", null: false
|
||||
t.bigint "web_push_subscription_id"
|
||||
t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
|
||||
t.index ["user_id"], name: "index_session_activations_on_user_id"
|
||||
@@ -295,9 +315,9 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.string "var", null: false
|
||||
t.text "value"
|
||||
t.string "thing_type"
|
||||
t.bigint "thing_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.bigint "thing_id"
|
||||
t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
|
||||
end
|
||||
|
||||
@@ -321,9 +341,8 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
|
||||
end
|
||||
|
||||
create_table "statuses", force: :cascade do |t|
|
||||
create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
|
||||
t.string "uri"
|
||||
t.bigint "account_id", null: false
|
||||
t.text "text", default: "", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
@@ -332,8 +351,6 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.string "url"
|
||||
t.boolean "sensitive", default: false, null: false
|
||||
t.integer "visibility", default: 0, null: false
|
||||
t.bigint "in_reply_to_account_id"
|
||||
t.bigint "application_id"
|
||||
t.text "spoiler_text", default: "", null: false
|
||||
t.boolean "reply", default: false, null: false
|
||||
t.integer "favourites_count", default: 0, null: false
|
||||
@@ -341,6 +358,9 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.string "language"
|
||||
t.bigint "conversation_id"
|
||||
t.boolean "local"
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "application_id"
|
||||
t.bigint "in_reply_to_account_id"
|
||||
t.index ["account_id", "id"], name: "index_statuses_on_account_id_id"
|
||||
t.index ["conversation_id"], name: "index_statuses_on_conversation_id"
|
||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
||||
@@ -356,12 +376,12 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
end
|
||||
|
||||
create_table "stream_entries", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "activity_id"
|
||||
t.string "activity_type"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "hidden", default: false, null: false
|
||||
t.bigint "account_id"
|
||||
t.index ["account_id"], name: "index_stream_entries_on_account_id"
|
||||
t.index ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type"
|
||||
end
|
||||
@@ -371,11 +391,11 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.string "secret"
|
||||
t.datetime "expires_at"
|
||||
t.boolean "confirmed", default: false, null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "last_successful_delivery_at"
|
||||
t.string "domain"
|
||||
t.bigint "account_id", null: false
|
||||
t.index ["account_id", "callback_url"], name: "index_subscriptions_on_account_id_and_callback_url", unique: true
|
||||
end
|
||||
|
||||
@@ -389,7 +409,6 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
@@ -415,6 +434,7 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
t.datetime "last_emailed_at"
|
||||
t.string "otp_backup_codes", array: true
|
||||
t.string "filtered_languages", default: [], null: false, array: true
|
||||
t.bigint "account_id", null: false
|
||||
t.index ["account_id"], name: "index_users_on_account_id"
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
@@ -432,53 +452,55 @@ ActiveRecord::Schema.define(version: 20170924022025) do
|
||||
end
|
||||
|
||||
create_table "web_settings", force: :cascade do |t|
|
||||
t.bigint "user_id"
|
||||
t.json "data"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "account_domain_blocks", "accounts", on_delete: :cascade
|
||||
add_foreign_key "blocks", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "blocks", "accounts", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "accounts", 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"
|
||||
add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
|
||||
add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
|
||||
add_foreign_key "favourites", "accounts", on_delete: :cascade
|
||||
add_foreign_key "favourites", "statuses", on_delete: :cascade
|
||||
add_foreign_key "follow_requests", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "follow_requests", "accounts", on_delete: :cascade
|
||||
add_foreign_key "follows", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "follows", "accounts", on_delete: :cascade
|
||||
add_foreign_key "imports", "accounts", on_delete: :cascade
|
||||
add_foreign_key "media_attachments", "accounts", on_delete: :nullify
|
||||
add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
|
||||
add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
|
||||
add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade
|
||||
add_foreign_key "follow_requests", "accounts", name: "fk_76d644b0e7", on_delete: :cascade
|
||||
add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
|
||||
add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
|
||||
add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
|
||||
add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
|
||||
add_foreign_key "media_attachments", "statuses", on_delete: :nullify
|
||||
add_foreign_key "mentions", "accounts", on_delete: :cascade
|
||||
add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
|
||||
add_foreign_key "mentions", "statuses", on_delete: :cascade
|
||||
add_foreign_key "mutes", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "mutes", "accounts", on_delete: :cascade
|
||||
add_foreign_key "notifications", "accounts", column: "from_account_id", on_delete: :cascade
|
||||
add_foreign_key "notifications", "accounts", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", on_delete: :cascade
|
||||
add_foreign_key "oauth_applications", "users", column: "owner_id", on_delete: :cascade
|
||||
add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", on_delete: :nullify
|
||||
add_foreign_key "reports", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "reports", "accounts", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "users", on_delete: :cascade
|
||||
add_foreign_key "status_pins", "accounts", on_delete: :cascade
|
||||
add_foreign_key "mutes", "accounts", column: "target_account_id", name: "fk_eecff219ea", on_delete: :cascade
|
||||
add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
|
||||
add_foreign_key "notifications", "accounts", column: "from_account_id", name: "fk_fbd6b0bf9e", on_delete: :cascade
|
||||
add_foreign_key "notifications", "accounts", name: "fk_c141c8ee55", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", name: "fk_34d54b0a33", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", name: "fk_63b044929b", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
|
||||
add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
|
||||
add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
|
||||
add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
|
||||
add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
|
||||
add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
|
||||
add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
|
||||
add_foreign_key "status_pins", "statuses", on_delete: :cascade
|
||||
add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", on_delete: :nullify
|
||||
add_foreign_key "statuses", "accounts", on_delete: :cascade
|
||||
add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", name: "fk_c7fa917661", on_delete: :nullify
|
||||
add_foreign_key "statuses", "accounts", name: "fk_9bda1543f7", on_delete: :cascade
|
||||
add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
|
||||
add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
|
||||
add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
|
||||
add_foreign_key "statuses_tags", "tags", on_delete: :cascade
|
||||
add_foreign_key "stream_entries", "accounts", on_delete: :cascade
|
||||
add_foreign_key "subscriptions", "accounts", on_delete: :cascade
|
||||
add_foreign_key "users", "accounts", on_delete: :cascade
|
||||
add_foreign_key "web_settings", "users", on_delete: :cascade
|
||||
add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
|
||||
add_foreign_key "stream_entries", "accounts", name: "fk_5659b17554", on_delete: :cascade
|
||||
add_foreign_key "subscriptions", "accounts", name: "fk_9847d1cbb5", on_delete: :cascade
|
||||
add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
|
||||
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user