Skip to content
Snippets Groups Projects
Commit 97c02c33 authored by aschmitz's avatar aschmitz Committed by Eugen Rochko
Browse files

Make IdsToBigints (mostly!) non-blocking (#5088)

* Make IdsToBigints (mostly!) non-blocking

This pulls in GitLab's MigrationHelpers, which include code to make
column changes in ways that Postgres can do without locking. In general,
this involves creating a new column, adding an index and any foreign
keys as appropriate, adding a trigger to keep it populated alongside
the old column, and then progressively copying data over to the new
column, before removing the old column and replacing it with the new
one.

A few changes to GitLab's MigrationHelpers were necessary:

* Some changes were made to remove dependencies on other GitLab code.
* We explicitly wait for index creation before forging ahead on column
  replacements.
* We use different temporary column names, to avoid running into index
  name length limits.
* We rename the generated indices back to what they "should" be after
  replacing columns.
* We rename the generated foreign keys to use the new column names when
  we had to create them. (This allows the migration to be rolled back
  without incident.)

# Big Scary Warning

There are two things here that may trip up large instances:

1. The change for tables' "id" columns is not concurrent. In
   particular, the stream_entries table may be big, and does not
   concurrently migrate its id column. (On the other hand, x_id type
   columns are all concurrent.)
2. This migration will take a long time to run, *but it should not
   lock tables during that time* (with the exception of the "id"
   columns as described above). That means this should probably be run
   in `screen` or some other session that can be run for a long time.
   Notably, the migration will take *longer* than it would without
   these changes, but the website will still be responsive during that
   time.

These changes were tested on a relatively large statuses table (256k
entries), and the service remained responsive during the migration.
Migrations both forward and backward were tested.

* Rubocop fixes

* MigrationHelpers: Support ID columns in some cases

This doesn't work in cases where the ID column is referred to as a
foreign key by another table.

* MigrationHelpers: support foreign keys for ID cols

Note that this does not yet support foreign keys on non-primary-key
columns, but Mastodon also doesn't yet have any that we've needed to
migrate.

This means we can perform fully "concurrent" migrations to change ID
column types, and the IdsToBigints migration can happen with effectively
no downtime. (A few operations require a transaction, such as renaming
columns or deleting them, but these transactions should not block for
noticeable amounts of time.)

The algorithm for generating foreign key names has changed with this,
and therefore all of those changed in schema.rb.

* Provide status, allow for interruptions

The MigrationHelpers now allow restarting the rename of a column if it
was interrupted, by removing the old "new column" and re-starting the
process.

Along with this, they now provide status updates on the changes which
are happening, as well as indications about when the changes can be
safely interrupted (when there are at least 10 seconds estimated to be
left before copying data is complete).

The IdsToBigints migration now also sorts the columns it migrates by
size, starting with the largest tables. This should provide
administrators a worst-case scenario estimate for the length of
migrations: each successive change will get faster, giving admins a
chance to abort early on if they need to run the migration later. The
idea is that this does not force them to try to time interruptions
between smaller migrations.

* Fix column sorting in IdsToBigints

Not a significant change, but it impacts the order of columns in the
database and db/schema.rb.

* Actually pause before IdsToBigints
parent 4453c9a9
No related branches found
No related tags found
No related merge requests found
Showing
with 1202 additions and 223 deletions
......@@ -3,11 +3,11 @@
#
# Table name: account_domain_blocks
#
# id :integer not null, primary key
# account_id :integer
# domain :string
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
# id :integer not null, primary key
#
class AccountDomainBlock < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: blocks
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# id :integer not null, primary key
# target_account_id :integer not null
#
class Block < ApplicationRecord
......
......@@ -3,9 +3,9 @@
#
# Table name: conversation_mutes
#
# id :integer not null, primary key
# account_id :integer not null
# conversation_id :integer not null
# account_id :integer not null
# id :integer not null, primary key
#
class ConversationMute < ApplicationRecord
......
......@@ -3,12 +3,12 @@
#
# Table name: domain_blocks
#
# id :integer not null, primary key
# domain :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# severity :integer default("silence")
# reject_media :boolean default(FALSE), not null
# id :integer not null, primary key
#
class DomainBlock < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: favourites
#
# id :integer not null, primary key
# account_id :integer not null
# status_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# id :integer not null, primary key
# status_id :integer not null
#
class Favourite < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: follows
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# id :integer not null, primary key
# target_account_id :integer not null
#
class Follow < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: follow_requests
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# id :integer not null, primary key
# target_account_id :integer not null
#
class FollowRequest < ApplicationRecord
......
......@@ -3,8 +3,6 @@
#
# Table name: imports
#
# id :integer not null, primary key
# account_id :integer not null
# type :integer not null
# approved :boolean default(FALSE), not null
# created_at :datetime not null
......@@ -13,6 +11,8 @@
# data_content_type :string
# data_file_size :integer
# data_updated_at :datetime
# account_id :integer not null
# id :integer not null, primary key
#
class Import < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: mentions
#
# id :integer not null, primary key
# account_id :integer
# status_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
# id :integer not null, primary key
#
class Mention < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: mutes
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# id :integer not null, primary key
# target_account_id :integer not null
#
class Mute < ApplicationRecord
......
......@@ -3,15 +3,15 @@
#
# Table name: reports
#
# id :integer not null, primary key
# account_id :integer not null
# target_account_id :integer not null
# status_ids :integer default([]), not null, is an Array
# comment :text default(""), not null
# action_taken :boolean default(FALSE), not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
# action_taken_by_account_id :integer
# id :integer not null, primary key
# target_account_id :integer not null
#
class Report < ApplicationRecord
......
......@@ -3,13 +3,13 @@
#
# Table name: settings
#
# id :integer not null, primary key
# var :string not null
# value :text
# thing_type :string
# thing_id :integer
# created_at :datetime
# updated_at :datetime
# id :integer not null, primary key
# thing_id :integer
#
class Setting < RailsSettings::Base
......
# frozen_string_literal: true
# == Schema Information
#
# Table name: stream_entries
#
# id :integer not null, primary key
# account_id :integer
# activity_id :integer
# activity_type :string
# created_at :datetime not null
# updated_at :datetime not null
# hidden :boolean default(FALSE), not null
# account_id :integer
# id :integer not null, primary key
#
class StreamEntry < ApplicationRecord
......
......@@ -3,16 +3,16 @@
#
# Table name: subscriptions
#
# id :integer not null, primary key
# callback_url :string default(""), not null
# secret :string
# expires_at :datetime
# confirmed :boolean default(FALSE), not null
# account_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# last_successful_delivery_at :datetime
# domain :string
# account_id :integer not null
# id :integer not null, primary key
#
class Subscription < ApplicationRecord
......
......@@ -3,11 +3,11 @@
#
# Table name: web_settings
#
# id :integer not null, primary key
# user_id :integer
# data :json
# created_at :datetime not null
# updated_at :datetime not null
# id :integer not null, primary key
# user_id :integer
#
class Web::Setting < ApplicationRecord
......
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
......@@ -16,10 +16,10 @@ ActiveRecord::Schema.define(version: 20170927215609) do
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
......@@ -69,16 +69,16 @@ ActiveRecord::Schema.define(version: 20170927215609) 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
......@@ -111,33 +111,32 @@ ActiveRecord::Schema.define(version: 20170927215609) do
end
create_table "favourites", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "status_id", null: false
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 +145,7 @@ ActiveRecord::Schema.define(version: 20170927215609) 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,12 +155,12 @@ ActiveRecord::Schema.define(version: 20170927215609) 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
......@@ -168,28 +168,28 @@ ActiveRecord::Schema.define(version: 20170927215609) do
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.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 +197,26 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +232,8 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +266,26 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +295,9 @@ ActiveRecord::Schema.define(version: 20170927215609) 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
......@@ -323,7 +323,6 @@ ActiveRecord::Schema.define(version: 20170927215609) do
create_table "statuses", 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 +331,6 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +338,9 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +356,12 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +371,11 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +389,6 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +414,7 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 +432,53 @@ ActiveRecord::Schema.define(version: 20170927215609) 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 "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
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment