Replace Makara with an initial Rails 6 role based splitting method.

This commit is contained in:
Free Speech Forever 2021-02-09 19:38:10 +00:00 committed by admin
parent 31922ea58b
commit 473c48b2aa
42 changed files with 3142 additions and 141 deletions

View File

@ -11,7 +11,6 @@ gem 'thor', '~> 0.20'
gem 'hamlit-rails', '~> 0.2' gem 'hamlit-rails', '~> 0.2'
gem 'pg', '~> 1.2.3' gem 'pg', '~> 1.2.3'
gem 'makara', '~> 0.4'
gem 'pghero', '~> 2.7.0' gem 'pghero', '~> 2.7.0'
gem 'dotenv-rails', '~> 2.7' gem 'dotenv-rails', '~> 2.7'

View File

@ -360,8 +360,6 @@ GEM
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
makara (0.5.0)
activerecord (>= 3.0.0)
marcel (0.3.3) marcel (0.3.3)
mimemagic (~> 0.3.2) mimemagic (~> 0.3.2)
mario-redis-lock (1.2.1) mario-redis-lock (1.2.1)
@ -728,7 +726,6 @@ DEPENDENCIES
link_header (~> 0.0) link_header (~> 0.0)
listen listen
lograge (~> 0.11) lograge (~> 0.11)
makara (~> 0.4)
mario-redis-lock (~> 1.2) mario-redis-lock (~> 1.2)
memory_profiler memory_profiler
microformats (~> 4.1) microformats (~> 4.1)

View File

@ -65,7 +65,11 @@ class Api::BaseController < ApplicationController
def current_resource_owner def current_resource_owner
if doorkeeper_token if doorkeeper_token
@current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do @current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do
User.find(doorkeeper_token.resource_owner_id) u = nil
ActiveRecord::Base.connected_to(role: :writing) do
u = User.find(doorkeeper_token.resource_owner_id)
end
u
end end
end end
return @current_user return @current_user

View File

@ -22,11 +22,17 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
private private
def set_account def set_account
ActiveRecord::Base.connected_to(role: :reading) do
@account = Account.find(params[:account_id]) @account = Account.find(params[:account_id])
end end
end
def load_statuses def load_statuses
cached_account_statuses cas = nil
ActiveRecord::Base.connected_to(role: :reading) do
cas = cached_account_statuses
end
cas
end end
def cached_account_statuses def cached_account_statuses

View File

@ -17,7 +17,11 @@ class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController
private private
def load_statuses def load_statuses
cached_bookmarks cb = nil
ActiveRecord::Base.connected_to(role: :reading) do
cb = cached_bookmarks
end
cb
end end
def cached_bookmarks def cached_bookmarks
@ -25,7 +29,7 @@ class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController
Status.reorder(nil).joins(:status_bookmarks).merge(results), Status.reorder(nil).joins(:status_bookmarks).merge(results),
Status Status
) )
end `` end
def results def results
@_results ||= account_bookmarks.paginate_by_id( @_results ||= account_bookmarks.paginate_by_id(

View File

@ -27,7 +27,6 @@ class Api::V1::NotificationsController < Api::BaseController
def mark_read def mark_read
if !params[:id].nil? and !current_account.user.nil? if !params[:id].nil? and !current_account.user.nil?
conn = ActiveRecord::Base.connection conn = ActiveRecord::Base.connection
conn.stick_to_master!
conn.exec_query "update users set last_read_notification = #{params[:id].to_i} where id = #{current_account.user.id}" conn.exec_query "update users set last_read_notification = #{params[:id].to_i} where id = #{current_account.user.id}"
end end
# current_account.notifications.find(params[:id]).mark_read! # current_account.notifications.find(params[:id]).mark_read!

View File

@ -34,14 +34,6 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
end end
def requested_status def requested_status
rs = nil Status.find(params[:status_id])
begin
rs = Status.find(params[:status_id])
rescue ActiveRecord::RecordNotFound
Status.connection.stick_to_master!
rs = Status.find(params[:status_id])
end
return rs unless rs.nil?
raise ActiveRecord::RecordNotFound
end end
end end

View File

@ -31,15 +31,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
private private
def status_for_reblog def status_for_reblog
rs = nil Status.find(params[:status_id])
begin
rs = Status.find(params[:status_id])
rescue ActiveRecord::RecordNotFound
Status.connection.stick_to_master!
rs = Status.find(params[:status_id])
end
return rs unless rs.nil?
raise ActiveRecord::RecordNotFound
end end
def status_for_destroy def status_for_destroy

View File

@ -39,7 +39,11 @@ class Api::V1::Timelines::ExploreController < Api::BaseController
end end
def cached_explore_statuses def cached_explore_statuses
cache_collection explore_statuses, Status es = nil
ActiveRecord::Base.connected_to(role: :reading) do
es = cache_collection explore_statuses, Status
end
es
end end
def explore_statuses def explore_statuses

View File

@ -56,7 +56,11 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
end end
def cached_group_collection_statuses def cached_group_collection_statuses
cache_collection group_collection_statuses, Status gcs = nil
ActiveRecord::Base.connected_to(role: :reading) do
gcs = cache_collection group_collection_statuses, Status
end
gcs
end end
def group_collection_statuses def group_collection_statuses

View File

@ -46,7 +46,11 @@ class Api::V1::Timelines::GroupController < Api::BaseController
end end
def cached_group_statuses def cached_group_statuses
cache_collection group_statuses, Status gs = nil
ActiveRecord::Base.connected_to(role: :reading) do
gs = cache_collection group_statuses, Status
end
gs
end end
def group_statuses def group_statuses

View File

@ -16,7 +16,11 @@ class Api::V1::Timelines::ProController < Api::BaseController
end end
def cached_pro_statuses def cached_pro_statuses
cache_collection pro_statuses, Status ps = nil
ActiveRecord::Base.connected_to(role: :reading) do
ps = cache_collection pro_statuses, Status
end
ps
end end
def pro_statuses def pro_statuses

View File

@ -90,7 +90,11 @@ class ApplicationController < ActionController::Base
def current_session def current_session
return nil if cookies.signed['_session_id'].nil? return nil if cookies.signed['_session_id'].nil?
@current_session ||= Rails.cache.fetch("dk:sess:#{cookies.signed['_session_id']}", expires_in: 25.hours) do @current_session ||= Rails.cache.fetch("dk:sess:#{cookies.signed['_session_id']}", expires_in: 25.hours) do
SessionActivation.find_by(session_id: cookies.signed['_session_id']) sa = nil
ActiveRecord::Base.connected_to(role: :writing) do
sa = SessionActivation.find_by(session_id: cookies.signed['_session_id'])
end
sa
end end
end end

View File

@ -10,7 +10,6 @@ class Auth::SessionsController < Devise::SessionsController
prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create] prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
before_action :set_instance_presenter, only: [:new] before_action :set_instance_presenter, only: [:new]
before_action :set_body_classes before_action :set_body_classes
before_action :use_master
def new def new
Devise.omniauth_configs.each do |provider, config| Devise.omniauth_configs.each do |provider, config|
@ -36,10 +35,6 @@ class Auth::SessionsController < Devise::SessionsController
protected protected
def use_master
User.connection.stick_to_master!
end
def find_user def find_user
if session[:otp_user_id] if session[:otp_user_id]
User.find(session[:otp_user_id]) User.find(session[:otp_user_id])

View File

@ -13,10 +13,11 @@ module SessionTrackingConcern
def set_session_activity def set_session_activity
return unless session_needs_update? return unless session_needs_update?
ActiveRecord::Base.connected_to(role: :writing) do
conn = ActiveRecord::Base.connection conn = ActiveRecord::Base.connection
conn.stick_to_master!
conn.exec_query "update session_activations set updated_at = NOW() where id = #{current_session.id}" conn.exec_query "update session_activations set updated_at = NOW() where id = #{current_session.id}"
end end
end
def session_needs_update? def session_needs_update?
!current_session.nil? && current_session.updated_at > UPDATE_SIGN_IN_HOURS.hours.ago !current_session.nil? && current_session.updated_at > UPDATE_SIGN_IN_HOURS.hours.ago

View File

@ -12,8 +12,10 @@ module UserTrackingConcern
private private
def set_user_activity def set_user_activity
ActiveRecord::Base.connected_to(role: :writing) do
current_user.update_sign_in!(request) if user_needs_sign_in_update? current_user.update_sign_in!(request) if user_needs_sign_in_update?
end end
end
def user_needs_sign_in_update? def user_needs_sign_in_update?
user_signed_in? && (current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < UPDATE_SIGN_IN_HOURS.hours.ago) user_signed_in? && (current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < UPDATE_SIGN_IN_HOURS.hours.ago)

View File

@ -9,6 +9,9 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
include Localized include Localized
include ForceDbWriterRole
around_action :force_writer_db_role, only: [:store_current_location, :render_success]
private private
def store_current_location def store_current_location

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class Oauth::TokensController < Doorkeeper::TokensController class Oauth::TokensController < Doorkeeper::TokensController
include ForceDbWriterRole
around_action :force_writer_db_role, only: :revoke
def revoke def revoke
unsubscribe_for_token if authorized? && token.accessible? unsubscribe_for_token if authorized? && token.accessible?
super super

View File

@ -108,7 +108,7 @@ class ReactController < ApplicationController
end end
def initial_state_params def initial_state_params
if !current_user.nil? if !current_user.nil? && !current_session.nil?
{ {
settings: Web::Setting.find_by(user: current_user)&.data || {}, settings: Web::Setting.find_by(user: current_user)&.data || {},
push_subscription: current_account.user.web_push_subscription(current_session), push_subscription: current_account.user.web_push_subscription(current_session),

View File

@ -0,0 +1,10 @@
module ForceDbWriterRole
extend ActiveSupport::Concern
# This is intended to be used as an around_action hook for GET
# endpoints that need to perform writes to ActiveRecord
def force_writer_db_role
ActiveRecord::Base.connected_to(role: :writing) do
yield
end
end
end

View File

@ -3,6 +3,7 @@
# #
# Table name: accounts # Table name: accounts
# #
# id :bigint(8) not null, primary key
# username :string default(""), not null # username :string default(""), not null
# domain :string # domain :string
# secret :string default(""), not null # secret :string default(""), not null
@ -19,11 +20,11 @@
# url :string # url :string
# avatar_file_name :string # avatar_file_name :string
# avatar_content_type :string # avatar_content_type :string
# avatar_file_size :bigint(8) # avatar_file_size :integer
# avatar_updated_at :datetime # avatar_updated_at :datetime
# header_file_name :string # header_file_name :string
# header_content_type :string # header_content_type :string
# header_file_size :bigint(8) # header_file_size :integer
# header_updated_at :datetime # header_updated_at :datetime
# avatar_remote_url :string # avatar_remote_url :string
# subscription_expires_at :datetime # subscription_expires_at :datetime
@ -35,7 +36,6 @@
# shared_inbox_url :string default(""), not null # shared_inbox_url :string default(""), not null
# followers_url :string default(""), not null # followers_url :string default(""), not null
# protocol :integer default(0), not null # protocol :integer default(0), not null
# id :bigint(8) not null, primary key
# memorial :boolean default(FALSE), not null # memorial :boolean default(FALSE), not null
# moved_to_account_id :bigint(8) # moved_to_account_id :bigint(8)
# featured_collection_url :string # featured_collection_url :string
@ -43,10 +43,10 @@
# actor_type :string # actor_type :string
# discoverable :boolean # discoverable :boolean
# also_known_as :string is an Array # also_known_as :string is an Array
# is_pro :boolean default(FALSE), not null
# pro_expires_at :datetime
# silenced_at :datetime # silenced_at :datetime
# suspended_at :datetime # suspended_at :datetime
# is_pro :boolean default(FALSE), not null
# pro_expires_at :datetime
# is_verified :boolean default(FALSE), not null # is_verified :boolean default(FALSE), not null
# is_donor :boolean default(FALSE), not null # is_donor :boolean default(FALSE), not null
# is_investor :boolean default(FALSE), not null # is_investor :boolean default(FALSE), not null

View File

@ -1,6 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
connects_to database: {
writing: :master,
reading: :slave1
}
self.abstract_class = true self.abstract_class = true
include Remotable include Remotable
end end

View File

@ -7,7 +7,7 @@
# user_id :bigint(8) # user_id :bigint(8)
# dump_file_name :string # dump_file_name :string
# dump_content_type :string # dump_content_type :string
# dump_file_size :bigint(8) # dump_file_size :integer
# dump_updated_at :datetime # dump_updated_at :datetime
# processed :boolean default(FALSE), not null # processed :boolean default(FALSE), not null
# created_at :datetime not null # created_at :datetime not null

View File

@ -8,7 +8,7 @@
# domain :string # domain :string
# image_file_name :string # image_file_name :string
# image_content_type :string # image_content_type :string
# image_file_size :bigint(8) # image_file_size :integer
# image_updated_at :datetime # image_updated_at :datetime
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null

View File

@ -8,7 +8,7 @@
# description :string not null # description :string not null
# cover_image_file_name :string # cover_image_file_name :string
# cover_image_content_type :string # cover_image_content_type :string
# cover_image_file_size :bigint(8) # cover_image_file_size :integer
# cover_image_updated_at :datetime # cover_image_updated_at :datetime
# is_nsfw :boolean default(FALSE), not null # is_nsfw :boolean default(FALSE), not null
# is_featured :boolean default(FALSE), not null # is_featured :boolean default(FALSE), not null
@ -18,7 +18,7 @@
# member_count :integer default(0) # member_count :integer default(0)
# slug :text # slug :text
# is_private :boolean default(FALSE) # is_private :boolean default(FALSE)
# is_visible :boolean default(TRUE) # is_visible :boolean default(FALSE)
# tags :string default([]), is an Array # tags :string default([]), is an Array
# password :string # password :string
# group_category_id :integer # group_category_id :integer

View File

@ -8,8 +8,10 @@ class HomeFeed < Feed
end end
def get(limit = 20, max_id = nil, since_id = nil, min_id = nil) def get(limit = 20, max_id = nil, since_id = nil, min_id = nil)
ActiveRecord::Base.connected_to(role: :reading) do
from_database(limit, max_id, since_id, min_id) from_database(limit, max_id, since_id, min_id)
end end
end
private private

View File

@ -6,7 +6,7 @@
# id :bigint(8) not null, primary key # id :bigint(8) not null, primary key
# list_id :bigint(8) not null # list_id :bigint(8) not null
# account_id :bigint(8) not null # account_id :bigint(8) not null
# follow_id :bigint(8) # follow_id :bigint(8) default(1)
# #
class ListAccount < ApplicationRecord class ListAccount < ApplicationRecord

View File

@ -3,10 +3,11 @@
# #
# Table name: media_attachments # Table name: media_attachments
# #
# id :bigint(8) not null, primary key
# status_id :bigint(8) # status_id :bigint(8)
# file_file_name :string # file_file_name :string
# file_content_type :string # file_content_type :string
# file_file_size :bigint(8) # file_file_size :integer
# file_updated_at :datetime # file_updated_at :datetime
# remote_url :string default(""), not null # remote_url :string default(""), not null
# created_at :datetime not null # created_at :datetime not null
@ -15,7 +16,6 @@
# type :integer default("image"), not null # type :integer default("image"), not null
# file_meta :json # file_meta :json
# account_id :bigint(8) # account_id :bigint(8)
# id :bigint(8) not null, primary key
# description :text # description :text
# scheduled_status_id :bigint(8) # scheduled_status_id :bigint(8)
# blurhash :string # blurhash :string

View File

@ -9,7 +9,7 @@
# description :string default(""), not null # description :string default(""), not null
# image_file_name :string # image_file_name :string
# image_content_type :string # image_content_type :string
# image_file_size :bigint(8) # image_file_size :integer
# image_updated_at :datetime # image_updated_at :datetime
# type :integer default("link"), not null # type :integer default("link"), not null
# html :text default(""), not null # html :text default(""), not null

View File

@ -44,10 +44,13 @@ class SessionActivation < ApplicationRecord
end end
def activate(**options) def activate(**options)
activation = nil
ActiveRecord::Base.connected_to(role: :writing) do
SessionActivation.record_timestamps = true SessionActivation.record_timestamps = true
activation = create!(options) activation = create!(options)
purge_old purge_old
SessionActivation.record_timestamps = false SessionActivation.record_timestamps = false
end
activation activation
end end
@ -72,6 +75,8 @@ class SessionActivation < ApplicationRecord
end end
def assign_access_token def assign_access_token
ActiveRecord::Base.connected_to(role: :writing) do
superapp = Doorkeeper::Application.find_by(superapp: true) superapp = Doorkeeper::Application.find_by(superapp: true)
self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id, self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id,
@ -80,4 +85,6 @@ class SessionActivation < ApplicationRecord
expires_in: Doorkeeper.configuration.access_token_expires_in, expires_in: Doorkeeper.configuration.access_token_expires_in,
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?) use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?)
end end
self.access_token
end
end end

View File

@ -7,7 +7,7 @@
# var :string default(""), not null # var :string default(""), not null
# file_file_name :string # file_file_name :string
# file_content_type :string # file_content_type :string
# file_file_size :bigint(8) # file_file_size :integer
# file_updated_at :datetime # file_updated_at :datetime
# meta :json # meta :json
# created_at :datetime not null # created_at :datetime not null

View File

@ -155,11 +155,17 @@ class User < ApplicationRecord
end end
def update_tracked_fields!(request) def update_tracked_fields!(request)
ru = nil
ActiveRecord::Base.connected_to(role: :writing) do
super super
prepare_returning_user! ru = prepare_returning_user!
end
ru
end end
def update_sign_in!(request, new_sign_in: false) def update_sign_in!(request, new_sign_in: false)
ru = nil
ActiveRecord::Base.connected_to(role: :writing) do
old_current, new_current = current_sign_in_at, Time.now.utc old_current, new_current = current_sign_in_at, Time.now.utc
self.last_sign_in_at = old_current || new_current self.last_sign_in_at = old_current || new_current
self.current_sign_in_at = new_current self.current_sign_in_at = new_current
@ -174,7 +180,9 @@ class User < ApplicationRecord
end end
save(validate: false) unless new_record? save(validate: false) unless new_record?
prepare_returning_user! ru = prepare_returning_user!
end
ru
end end
def disable_two_factor! def disable_two_factor!
@ -233,6 +241,7 @@ class User < ApplicationRecord
end end
def web_push_subscription(session) def web_push_subscription(session)
return nil if session.nil?
session.web_push_subscription.nil? ? nil : session.web_push_subscription session.web_push_subscription.nil? ? nil : session.web_push_subscription
end end

View File

@ -14,7 +14,6 @@ class FavouriteService < BaseService
begin begin
favourite = Favourite.find_by(account: account, status: status) favourite = Favourite.find_by(account: account, status: status)
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
Favourite.connection.stick_to_master!
favourite = Favourite.find_by(account: account, status: status) favourite = Favourite.find_by(account: account, status: status)
end end

View File

@ -153,7 +153,6 @@ class PostStatusService < BaseService
raise GabSocial::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present? raise GabSocial::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
@account.media_attachments.connection.stick_to_master!
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)) @media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
hasVideoOrGif = @media.find(&:video?) || @media.find(&:gifv?) hasVideoOrGif = @media.find(&:video?) || @media.find(&:gifv?)

View File

@ -14,12 +14,7 @@ class ReblogService < BaseService
authorize_with account, reblogged_status, :reblog? authorize_with account, reblogged_status, :reblog?
reblog = nil reblog = nil
begin
reblog = account.statuses.find_by(reblog: reblogged_status) reblog = account.statuses.find_by(reblog: reblogged_status)
rescue ActiveRecord::RecordNotFound
account.statuses.connection.stick_to_master!
reblog = account.statuses.find_by(reblog: reblogged_status)
end
return reblog unless reblog.nil? return reblog unless reblog.nil?

View File

@ -6,21 +6,24 @@ default: &default
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %> sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
development: development:
<<: *default master:
adapter: postgresql_makara adapter: postgresql
prepared_statements: false url: <%= ENV['DB_MASTER_URL'] %>
database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> pool: <%= ENV['DB_POOL'] %>
username: <%= ENV['DB_USER'] %> timeout: 5000
password: <%= ENV['DB_PASS'] %> encoding: unicode
host: <%= ENV['DB_HOST'] %> slave1:
port: <%= ENV['DB_PORT'] %> adapter: postgresql
makara: url: <%= ENV['DB_SLAVE1_URL'] %>
id: postgres pool: <%= ENV['DB_POOL'] %>
sticky: true timeout: 5000
connections: encoding: unicode
- role: master slave2:
blacklist_duration: 0 adapter: postgresql
- role: slave url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
@ -33,12 +36,34 @@ test:
host: <%= ENV['DB_HOST'] %> host: <%= ENV['DB_HOST'] %>
port: <%= ENV['DB_PORT'] %> port: <%= ENV['DB_PORT'] %>
production: #production:
<<: *default # <<: *default
database: <%= ENV['DB_NAME'] || 'gabsocial_production' %> # database: <%= ENV['DB_NAME'] || 'gabsocial_production' %>
username: <%= ENV['DB_USER'] || 'gabsocial' %> # username: <%= ENV['DB_USER'] || 'gabsocial' %>
password: <%= ENV['DB_PASS'] || '' %> # password: <%= ENV['DB_PASS'] || '' %>
host: <%= ENV['DB_HOST'] || 'localhost' %> # host: <%= ENV['DB_HOST'] || 'localhost' %>
port: <%= ENV['DB_PORT'] || 5432 %> # port: <%= ENV['DB_PORT'] || 5432 %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %> # prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>
production:
master:
adapter: postgresql
url: <%= ENV['DB_MASTER_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
slave1:
adapter: postgresql
url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode
slave2:
adapter: postgresql
url: <%= ENV['DB_SLAVE1_URL'] %>
pool: <%= ENV['DB_POOL'] %>
timeout: 5000
encoding: unicode

View File

@ -131,7 +131,7 @@ Rails.application.configure do
# DatabaseSelector middleware is designed as such you can define your own # DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through # strategy for connection switching and pass that into the middleware through
# these configuration options. # these configuration options.
# config.active_record.database_selector = { delay: 2.seconds } config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end end

View File

@ -1,9 +1,12 @@
Warden::Manager.after_set_user except: :fetch do |user, warden| Warden::Manager.after_set_user except: :fetch do |user, warden|
session_id = nil
ActiveRecord::Base.connected_to(role: :writing) do
if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id']) if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'])
session_id = warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'] session_id = warden.cookies.signed['_session_id'] || warden.raw_session['auth_id']
else else
session_id = user.activate_session(warden.request) session_id = user.activate_session(warden.request)
end end
end
warden.cookies.signed['_session_id'] = { warden.cookies.signed['_session_id'] = {
value: session_id, value: session_id,
@ -14,6 +17,7 @@ Warden::Manager.after_set_user except: :fetch do |user, warden|
end end
Warden::Manager.after_fetch do |user, warden| Warden::Manager.after_fetch do |user, warden|
ActiveRecord::Base.connected_to(role: :writing) do
if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id']) if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'])
warden.cookies.signed['_session_id'] = { warden.cookies.signed['_session_id'] = {
value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'], value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'],
@ -26,6 +30,8 @@ Warden::Manager.after_fetch do |user, warden|
throw :warden, message: :unauthenticated throw :warden, message: :unauthenticated
end end
end end
warden.cookies.signed['_session_id']
end
Warden::Manager.before_logout do |_, warden| Warden::Manager.before_logout do |_, warden|
SessionActivation.deactivate warden.cookies.signed['_session_id'] SessionActivation.deactivate warden.cookies.signed['_session_id']

View File

@ -16,9 +16,6 @@ Rails.application.routes.draw do
mount PgHero::Engine, at: 'pghero', as: :pghero mount PgHero::Engine, at: 'pghero', as: :pghero
end end
Doorkeeper::AccessToken.connection.stick_to_master!
Doorkeeper::AccessGrant.connection.stick_to_master!
SessionActivation.connection.stick_to_master!
SessionActivation.record_timestamps = false SessionActivation.record_timestamps = false
use_doorkeeper do use_doorkeeper do

977
db/master_schema.rb Normal file
View File

@ -0,0 +1,977 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_01_23_050026) do
# These are extensions that must be enabled in order to support this database
enable_extension "hypopg"
enable_extension "pg_stat_statements"
enable_extension "pgstattuple"
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 ["conversation_id"], name: "index_account_conversations_on_conversation_id"
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 "account_stats", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "statuses_count", default: 0, null: false
t.bigint "following_count", default: 0, null: false
t.bigint "followers_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "last_status_at"
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
end
create_table "account_tag_stats", force: :cascade do |t|
t.bigint "tag_id", null: false
t.bigint "accounts_count", default: 0, null: false
t.boolean "hidden", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["tag_id"], name: "index_account_tag_stats_on_tag_id", unique: true
end
create_table "account_username_changes", force: :cascade do |t|
t.bigint "account_id", null: false
t.text "from_username", default: "", null: false
t.text "to_username", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_username_changes_on_account_id"
end
create_table "account_verification_requests", force: :cascade do |t|
t.bigint "account_id"
t.string "image_file_name"
t.string "image_content_type"
t.bigint "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_verification_requests_on_account_id"
end
create_table "account_warning_presets", force: :cascade do |t|
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "account_warnings", force: :cascade do |t|
t.bigint "account_id"
t.bigint "target_account_id"
t.integer "action", default: 0, null: false
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_warnings_on_account_id"
t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
end
create_table "accounts", force: :cascade do |t|
t.string "username", default: "", null: false
t.string "domain"
t.string "secret", default: "", null: false
t.text "private_key"
t.text "public_key", default: "", null: false
t.string "remote_url", default: "", null: false
t.string "salmon_url", default: "", null: false
t.string "hub_url", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "note", default: "", null: false
t.string "display_name", default: "", null: false
t.string "uri", default: "", null: false
t.string "url"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.string "header_file_name"
t.string "header_content_type"
t.integer "header_file_size"
t.datetime "header_updated_at"
t.string "avatar_remote_url"
t.datetime "subscription_expires_at"
t.boolean "locked", default: false, null: false
t.string "header_remote_url", default: "", null: false
t.datetime "last_webfingered_at"
t.string "inbox_url", default: "", null: false
t.string "outbox_url", default: "", null: false
t.string "shared_inbox_url", default: "", null: false
t.string "followers_url", default: "", null: false
t.integer "protocol", default: 0, null: false
t.boolean "memorial", default: false, null: false
t.bigint "moved_to_account_id"
t.string "featured_collection_url"
t.jsonb "fields"
t.string "actor_type"
t.boolean "discoverable"
t.string "also_known_as", array: true
t.datetime "silenced_at"
t.datetime "suspended_at"
t.boolean "is_pro", default: false, null: false
t.datetime "pro_expires_at"
t.boolean "is_verified", default: false, null: false
t.boolean "is_donor", default: false, null: false
t.boolean "is_investor", default: false, null: false
t.boolean "is_flagged_as_spam", default: false, null: false
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
t.index ["domain"], name: "index_accounts_on_domain"
t.index ["is_donor"], name: "index_accounts_on_is_donor"
t.index ["is_investor"], name: "index_accounts_on_is_investor"
t.index ["is_pro"], name: "index_accounts_on_is_pro"
t.index ["is_verified"], name: "index_accounts_on_is_verified"
t.index ["locked"], name: "index_accounts_on_locked"
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
t.index ["uri"], name: "index_accounts_on_uri"
t.index ["url"], name: "index_accounts_on_url"
end
create_table "accounts_tags", id: false, force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "tag_id", null: false
t.index ["account_id", "tag_id"], name: "index_accounts_tags_on_account_id_and_tag_id"
t.index ["tag_id", "account_id"], name: "index_accounts_tags_on_tag_id_and_account_id", unique: true
end
create_table "admin_action_logs", force: :cascade do |t|
t.bigint "account_id"
t.string "action", default: "", null: false
t.string "target_type"
t.bigint "target_id"
t.text "recorded_changes", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_admin_action_logs_on_account_id"
t.index ["target_type", "target_id"], name: "index_admin_action_logs_on_target_type_and_target_id"
end
create_table "backups", force: :cascade do |t|
t.bigint "user_id"
t.string "dump_file_name"
t.string "dump_content_type"
t.integer "dump_file_size"
t.datetime "dump_updated_at"
t.boolean "processed", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "blocks", force: :cascade do |t|
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.string "uri"
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
end
create_table "btc_payments", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "btcpay_invoice_id", null: false
t.string "plan", null: false
t.boolean "success", default: false, null: false
end
create_table "chat_blocks", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "target_account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "target_account_id"], name: "index_chat_blocks_on_account_id_and_target_account_id", unique: true
end
create_table "chat_conversation_accounts", force: :cascade do |t|
t.bigint "account_id"
t.bigint "chat_conversation_id"
t.bigint "participant_account_ids", default: [], null: false, array: true
t.bigint "last_chat_message_id"
t.boolean "is_hidden", default: false, null: false
t.boolean "is_approved", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "unread_count", default: 0
t.string "chat_message_expiration_policy"
t.boolean "is_muted", default: false, null: false
t.index ["account_id"], name: "index_chat_conversation_accounts_on_account_id"
t.index ["chat_conversation_id"], name: "index_chat_conversation_accounts_on_chat_conversation_id"
end
create_table "chat_conversations", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "chat_messages", force: :cascade do |t|
t.text "text", default: "", null: false
t.text "language", default: "", null: false
t.integer "from_account_id", null: false
t.integer "chat_conversation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.index ["from_account_id", "chat_conversation_id"], name: "index_chat_messages_on_from_account_id_and_chat_conversation_id"
end
create_table "conversations", force: :cascade do |t|
t.string "uri"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["uri"], name: "index_conversations_on_uri", unique: true
end
create_table "custom_emojis", force: :cascade do |t|
t.string "shortcode", default: "", null: false
t.string "domain"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.string "image_remote_url"
t.boolean "visible_in_picker", default: true, null: false
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
end
create_table "custom_filters", force: :cascade do |t|
t.bigint "account_id"
t.datetime "expires_at"
t.text "phrase", default: "", null: false
t.string "context", default: [], null: false, array: true
t.boolean "irreversible", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "whole_word", default: true, null: false
t.index ["account_id"], name: "index_custom_filters_on_account_id"
end
create_table "email_domain_blocks", force: :cascade do |t|
t.string "domain", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_follows_on_target_account_id"
end
create_table "group_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.boolean "write_permissions", default: false, null: false
t.string "role"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_accounts_on_group_id_and_account_id"
end
create_table "group_categories", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "text", default: "", null: false
end
create_table "group_join_requests", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "group_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_join_requests_on_account_id_and_group_id", unique: true
t.index ["group_id"], name: "index_group_join_requests_on_group_id"
end
create_table "group_pinned_statuses", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "group_id", null: false
t.index ["group_id"], name: "index_group_pinned_statuses_on_group_id"
t.index ["status_id", "group_id"], name: "index_group_pinned_statuses_on_status_id_and_group_id", unique: true
end
create_table "group_removed_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_removed_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_removed_accounts_on_group_id_and_account_id"
end
create_table "groups", force: :cascade do |t|
t.bigint "account_id"
t.string "title", null: false
t.string "description", null: false
t.string "cover_image_file_name"
t.string "cover_image_content_type"
t.integer "cover_image_file_size"
t.datetime "cover_image_updated_at"
t.boolean "is_nsfw", default: false, null: false
t.boolean "is_featured", default: false, null: false
t.boolean "is_archived", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "member_count", default: 0
t.text "slug"
t.boolean "is_private", default: false
t.boolean "is_visible", default: true
t.string "tags", default: [], array: true
t.string "password"
t.integer "group_category_id"
t.index ["account_id"], name: "index_groups_on_account_id"
t.index ["slug"], name: "index_groups_on_slug", unique: true
end
create_table "identities", force: :cascade do |t|
t.string "provider", default: "", null: false
t.string "uid", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id"
t.index ["user_id"], name: "index_identities_on_user_id"
end
create_table "link_blocks", force: :cascade do |t|
t.string "link", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["link"], name: "index_link_blocks_on_link", unique: true
end
create_table "list_accounts", force: :cascade do |t|
t.bigint "list_id", null: false
t.bigint "account_id", null: false
t.bigint "follow_id"
t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
t.index ["follow_id"], name: "index_list_accounts_on_follow_id"
t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
end
create_table "lists", force: :cascade do |t|
t.bigint "account_id", null: false
t.string "title", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_lists_on_account_id"
end
create_table "media_attachment_albums", force: :cascade do |t|
t.text "title", default: "", null: false
t.text "description"
t.integer "account_id", null: false
t.integer "visibility", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "cover_id"
t.integer "count", default: 0, null: false
t.index ["cover_id"], name: "index_media_attachment_albums_on_cover_id"
end
create_table "media_attachments", force: :cascade do |t|
t.bigint "status_id"
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.string "remote_url", default: "", null: false
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.bigint "scheduled_status_id"
t.string "blurhash"
t.bigint "media_attachment_album_id"
t.index ["account_id"], name: "index_media_attachments_on_account_id"
t.index ["media_attachment_album_id"], name: "index_media_attachments_on_media_attachment_album_id"
t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
t.index ["status_id"], name: "index_media_attachments_on_status_id"
t.index ["type"], name: "index_media_attachments_on_type"
end
create_table "mentions", force: :cascade do |t|
t.bigint "status_id"
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
create_table "mutes", force: :cascade do |t|
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
t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
end
create_table "notifications", force: :cascade do |t|
t.bigint "activity_id", null: false
t.string "activity_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "from_account_id", null: false
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
t.index ["account_id", "id"], name: "index_notifications_on_account_id_and_id", order: { id: :desc }
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
end
create_table "oauth_access_grants", force: :cascade do |t|
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 ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
end
create_table "oauth_access_tokens", force: :cascade do |t|
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
end
create_table "oauth_applications", force: :cascade do |t|
t.string "name", null: false
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
t.string "scopes", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "superapp", default: false, null: false
t.string "website"
t.string "owner_type"
t.bigint "owner_id"
t.boolean "confidential", default: true, null: false
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
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 "poll_votes", force: :cascade do |t|
t.bigint "account_id"
t.bigint "poll_id"
t.integer "choice", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.index ["account_id"], name: "index_poll_votes_on_account_id"
t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
end
create_table "polls", force: :cascade do |t|
t.bigint "account_id"
t.bigint "status_id"
t.datetime "expires_at"
t.string "options", default: [], null: false, array: true
t.bigint "cached_tallies", default: [], null: false, array: true
t.boolean "multiple", default: false, null: false
t.boolean "hide_totals", default: false, null: false
t.bigint "votes_count", default: 0, null: false
t.datetime "last_fetched_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lock_version", default: 0, null: false
t.index ["account_id"], name: "index_polls_on_account_id"
t.index ["created_at"], name: "index_polls_on_created_at"
t.index ["id", "lock_version"], name: "index_polls_on_id_and_lock_version"
t.index ["status_id"], name: "index_polls_on_status_id"
end
create_table "preview_cards", force: :cascade do |t|
t.string "url", default: "", null: false
t.string "title", default: "", null: false
t.string "description", default: "", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.integer "type", default: 0, null: false
t.text "html", default: "", null: false
t.string "author_name", default: "", null: false
t.string "author_url", default: "", null: false
t.string "provider_name", default: "", null: false
t.string "provider_url", default: "", null: false
t.integer "width", default: 0, null: false
t.integer "height", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "embed_url", default: "", null: false
t.index ["url"], name: "index_preview_cards_on_url", unique: true
end
create_table "preview_cards_statuses", id: false, force: :cascade do |t|
t.bigint "preview_card_id", null: false
t.bigint "status_id", null: false
t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
end
create_table "promotions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.bigint "status_id", null: false
t.string "timeline_id"
t.integer "position", default: 10
end
create_table "report_notes", force: :cascade do |t|
t.text "content", null: false
t.bigint "report_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_report_notes_on_account_id"
t.index ["report_id"], name: "index_report_notes_on_report_id"
end
create_table "reports", force: :cascade do |t|
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.bigint "assigned_account_id"
t.string "uri"
t.index ["account_id"], name: "index_reports_on_account_id"
t.index ["action_taken"], name: "index_reports_on_action_taken"
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
end
create_table "scheduled_statuses", force: :cascade do |t|
t.bigint "account_id"
t.datetime "scheduled_at"
t.jsonb "params"
t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
end
create_table "session_activations", force: :cascade do |t|
t.string "session_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, 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 ["access_token_id"], name: "index_session_activations_on_access_token_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"
end
create_table "settings", force: :cascade do |t|
t.string "var", null: false
t.text "value"
t.string "thing_type"
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
create_table "shortcuts", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "shortcut_id", null: false
t.string "shortcut_type", default: "", null: false
t.index ["account_id", "shortcut_id", "shortcut_type"], name: "index_shortcuts_on_account_id_and_shortcut_id_and_shortcut_type", unique: true
end
create_table "site_uploads", force: :cascade do |t|
t.string "var", default: "", null: false
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.json "meta"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["var"], name: "index_site_uploads_on_var", unique: true
end
create_table "status_bookmark_collections", force: :cascade do |t|
t.text "title", default: "", null: false
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "status_bookmarks", 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.bigint "status_bookmark_collection_id"
t.index ["account_id", "status_id"], name: "index_status_bookmarks_on_account_id_and_status_id", unique: true
t.index ["status_bookmark_collection_id"], name: "index_status_bookmarks_on_status_bookmark_collection_id"
t.index ["status_id"], name: "index_status_bookmarks_on_status_id"
end
create_table "status_pins", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "status_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, null: false
t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
end
create_table "status_revisions", force: :cascade do |t|
t.bigint "status_id"
t.string "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["status_id"], name: "index_status_revisions_on_status_id"
end
create_table "status_stats", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "replies_count", default: 0, null: false
t.bigint "reblogs_count", default: 0, null: false
t.bigint "favourites_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["created_at"], name: "index_status_stats_on_created_at"
t.index ["favourites_count"], name: "index_status_stats_on_favourites_count"
t.index ["reblogs_count"], name: "index_status_stats_on_reblogs_count"
t.index ["replies_count"], name: "index_status_stats_on_replies_count"
t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
t.index ["updated_at"], name: "index_status_stats_on_updated_at"
end
create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
t.string "uri"
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "in_reply_to_id"
t.bigint "reblog_of_id"
t.string "url"
t.boolean "sensitive", default: false, null: false
t.integer "visibility", default: 0, null: false
t.text "spoiler_text", default: "", null: false
t.boolean "reply", default: false, null: false
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.bigint "poll_id"
t.integer "group_id"
t.bigint "quote_of_id"
t.datetime "revised_at"
t.text "markdown"
t.datetime "expires_at"
t.boolean "has_quote"
t.index ["account_id", "id", "visibility", "created_at"], name: "index_statuses_20201206", order: { id: :desc }
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
t.index ["created_at", "reply", "reblog_of_id", "account_id", "group_id"], name: "index_statuses_on_created_at_desc_account", order: { created_at: :desc }
t.index ["created_at", "reply", "reblog_of_id"], name: "index_statuses_on_created_at_desc_account_id", order: { created_at: :desc }
t.index ["created_at"], name: "index_statuses_on_created_at"
t.index ["group_id", "reply", "reblog_of_id", "account_id"], name: "index_statuses_group_id_reply"
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
t.index ["quote_of_id"], name: "index_statuses_on_quote_of_id"
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
t.index ["reply"], name: "index_statuses_on_reply"
t.index ["updated_at"], name: "index_statuses_on_updated_at"
t.index ["uri"], name: "index_statuses_on_uri", unique: true
end
create_table "statuses_tags", id: false, force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "tag_id", null: false
t.index ["status_id"], name: "index_statuses_tags_on_status_id"
t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
end
create_table "tags", force: :cascade do |t|
t.string "name", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text) text_pattern_ops", name: "hashtag_search_index"
t.index ["name"], name: "index_tags_on_name", unique: true
end
create_table "tombstones", force: :cascade do |t|
t.bigint "account_id"
t.string "uri", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "by_moderator"
t.index ["account_id"], name: "index_tombstones_on_account_id"
t.index ["uri"], name: "index_tombstones_on_uri"
end
create_table "transactions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "payment_type"
t.string "provider_type"
t.text "provider_response"
t.integer "amount", null: false
t.boolean "success", default: false, null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.boolean "admin", default: false, null: false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.string "locale"
t.string "encrypted_otp_secret"
t.string "encrypted_otp_secret_iv"
t.string "encrypted_otp_secret_salt"
t.integer "consumed_timestep"
t.boolean "otp_required_for_login", default: false, null: false
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.boolean "disabled", default: false, null: false
t.boolean "moderator", default: false, null: false
t.string "remember_token"
t.string "chosen_languages", array: true
t.bigint "created_by_application_id"
t.boolean "approved", default: true, null: false
t.bigint "last_read_notification"
t.string "unique_email"
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["created_at"], name: "index_users_on_created_at"
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
t.index ["current_sign_in_at"], name: "index_users_on_current_sign_in_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["remember_token"], name: "index_users_on_remember_token"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unique_email"], name: "index_users_on_unique_email"
end
create_table "web_push_subscriptions", force: :cascade do |t|
t.string "endpoint", null: false
t.string "key_p256dh", null: false
t.string "key_auth", null: false
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "access_token_id"
t.bigint "user_id"
t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id"
t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
end
create_table "web_settings", force: :cascade do |t|
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
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_moderation_notes", "accounts"
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
add_foreign_key "account_stats", "accounts", on_delete: :cascade
add_foreign_key "account_tag_stats", "tags", on_delete: :cascade
add_foreign_key "account_username_changes", "accounts", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", on_delete: :nullify
add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
add_foreign_key "backups", "users", on_delete: :nullify
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 "chat_blocks", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "chat_blocks", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_conversations", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_messages", column: "last_chat_message_id", on_delete: :nullify
add_foreign_key "chat_messages", "accounts", column: "from_account_id", on_delete: :cascade
add_foreign_key "chat_messages", "chat_conversations", on_delete: :cascade
add_foreign_key "custom_filters", "accounts", on_delete: :cascade
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 "group_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_accounts", "groups", on_delete: :cascade
add_foreign_key "group_join_requests", "accounts", on_delete: :cascade
add_foreign_key "group_join_requests", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "statuses", on_delete: :cascade
add_foreign_key "group_removed_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_removed_accounts", "groups", on_delete: :cascade
add_foreign_key "groups", "group_categories", on_delete: :nullify
add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
add_foreign_key "list_accounts", "accounts", on_delete: :cascade
add_foreign_key "list_accounts", "follows", on_delete: :cascade
add_foreign_key "list_accounts", "lists", on_delete: :cascade
add_foreign_key "lists", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "media_attachments", column: "cover_id", on_delete: :nullify
add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
add_foreign_key "media_attachments", "media_attachment_albums", on_delete: :nullify
add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
add_foreign_key "media_attachments", "statuses", on_delete: :nullify
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", 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 "poll_votes", "accounts", on_delete: :cascade
add_foreign_key "poll_votes", "polls", on_delete: :cascade
add_foreign_key "polls", "accounts", on_delete: :cascade
add_foreign_key "polls", "statuses", on_delete: :cascade
add_foreign_key "report_notes", "accounts", on_delete: :cascade
add_foreign_key "report_notes", "reports", 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: "assigned_account_id", 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 "scheduled_statuses", "accounts", 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 "shortcuts", "accounts", on_delete: :cascade
add_foreign_key "status_bookmark_collections", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "status_bookmark_collections", on_delete: :nullify
add_foreign_key "status_bookmarks", "statuses", 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 "status_stats", "statuses", 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", "groups", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "quote_of_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", name: "fk_3081861e21", on_delete: :cascade
add_foreign_key "tombstones", "accounts", on_delete: :cascade
add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
end

977
db/slave1_schema.rb Normal file
View File

@ -0,0 +1,977 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_01_23_050026) do
# These are extensions that must be enabled in order to support this database
enable_extension "hypopg"
enable_extension "pg_stat_statements"
enable_extension "pgstattuple"
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 ["conversation_id"], name: "index_account_conversations_on_conversation_id"
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 "account_stats", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "statuses_count", default: 0, null: false
t.bigint "following_count", default: 0, null: false
t.bigint "followers_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "last_status_at"
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
end
create_table "account_tag_stats", force: :cascade do |t|
t.bigint "tag_id", null: false
t.bigint "accounts_count", default: 0, null: false
t.boolean "hidden", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["tag_id"], name: "index_account_tag_stats_on_tag_id", unique: true
end
create_table "account_username_changes", force: :cascade do |t|
t.bigint "account_id", null: false
t.text "from_username", default: "", null: false
t.text "to_username", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_username_changes_on_account_id"
end
create_table "account_verification_requests", force: :cascade do |t|
t.bigint "account_id"
t.string "image_file_name"
t.string "image_content_type"
t.bigint "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_verification_requests_on_account_id"
end
create_table "account_warning_presets", force: :cascade do |t|
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "account_warnings", force: :cascade do |t|
t.bigint "account_id"
t.bigint "target_account_id"
t.integer "action", default: 0, null: false
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_warnings_on_account_id"
t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
end
create_table "accounts", force: :cascade do |t|
t.string "username", default: "", null: false
t.string "domain"
t.string "secret", default: "", null: false
t.text "private_key"
t.text "public_key", default: "", null: false
t.string "remote_url", default: "", null: false
t.string "salmon_url", default: "", null: false
t.string "hub_url", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "note", default: "", null: false
t.string "display_name", default: "", null: false
t.string "uri", default: "", null: false
t.string "url"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.string "header_file_name"
t.string "header_content_type"
t.integer "header_file_size"
t.datetime "header_updated_at"
t.string "avatar_remote_url"
t.datetime "subscription_expires_at"
t.boolean "locked", default: false, null: false
t.string "header_remote_url", default: "", null: false
t.datetime "last_webfingered_at"
t.string "inbox_url", default: "", null: false
t.string "outbox_url", default: "", null: false
t.string "shared_inbox_url", default: "", null: false
t.string "followers_url", default: "", null: false
t.integer "protocol", default: 0, null: false
t.boolean "memorial", default: false, null: false
t.bigint "moved_to_account_id"
t.string "featured_collection_url"
t.jsonb "fields"
t.string "actor_type"
t.boolean "discoverable"
t.string "also_known_as", array: true
t.datetime "silenced_at"
t.datetime "suspended_at"
t.boolean "is_pro", default: false, null: false
t.datetime "pro_expires_at"
t.boolean "is_verified", default: false, null: false
t.boolean "is_donor", default: false, null: false
t.boolean "is_investor", default: false, null: false
t.boolean "is_flagged_as_spam", default: false, null: false
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
t.index ["domain"], name: "index_accounts_on_domain"
t.index ["is_donor"], name: "index_accounts_on_is_donor"
t.index ["is_investor"], name: "index_accounts_on_is_investor"
t.index ["is_pro"], name: "index_accounts_on_is_pro"
t.index ["is_verified"], name: "index_accounts_on_is_verified"
t.index ["locked"], name: "index_accounts_on_locked"
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
t.index ["uri"], name: "index_accounts_on_uri"
t.index ["url"], name: "index_accounts_on_url"
end
create_table "accounts_tags", id: false, force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "tag_id", null: false
t.index ["account_id", "tag_id"], name: "index_accounts_tags_on_account_id_and_tag_id"
t.index ["tag_id", "account_id"], name: "index_accounts_tags_on_tag_id_and_account_id", unique: true
end
create_table "admin_action_logs", force: :cascade do |t|
t.bigint "account_id"
t.string "action", default: "", null: false
t.string "target_type"
t.bigint "target_id"
t.text "recorded_changes", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_admin_action_logs_on_account_id"
t.index ["target_type", "target_id"], name: "index_admin_action_logs_on_target_type_and_target_id"
end
create_table "backups", force: :cascade do |t|
t.bigint "user_id"
t.string "dump_file_name"
t.string "dump_content_type"
t.integer "dump_file_size"
t.datetime "dump_updated_at"
t.boolean "processed", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "blocks", force: :cascade do |t|
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.string "uri"
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
end
create_table "btc_payments", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "btcpay_invoice_id", null: false
t.string "plan", null: false
t.boolean "success", default: false, null: false
end
create_table "chat_blocks", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "target_account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "target_account_id"], name: "index_chat_blocks_on_account_id_and_target_account_id", unique: true
end
create_table "chat_conversation_accounts", force: :cascade do |t|
t.bigint "account_id"
t.bigint "chat_conversation_id"
t.bigint "participant_account_ids", default: [], null: false, array: true
t.bigint "last_chat_message_id"
t.boolean "is_hidden", default: false, null: false
t.boolean "is_approved", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "unread_count", default: 0
t.string "chat_message_expiration_policy"
t.boolean "is_muted", default: false, null: false
t.index ["account_id"], name: "index_chat_conversation_accounts_on_account_id"
t.index ["chat_conversation_id"], name: "index_chat_conversation_accounts_on_chat_conversation_id"
end
create_table "chat_conversations", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "chat_messages", force: :cascade do |t|
t.text "text", default: "", null: false
t.text "language", default: "", null: false
t.integer "from_account_id", null: false
t.integer "chat_conversation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.index ["from_account_id", "chat_conversation_id"], name: "index_chat_messages_on_from_account_id_and_chat_conversation_id"
end
create_table "conversations", force: :cascade do |t|
t.string "uri"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["uri"], name: "index_conversations_on_uri", unique: true
end
create_table "custom_emojis", force: :cascade do |t|
t.string "shortcode", default: "", null: false
t.string "domain"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.string "image_remote_url"
t.boolean "visible_in_picker", default: true, null: false
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
end
create_table "custom_filters", force: :cascade do |t|
t.bigint "account_id"
t.datetime "expires_at"
t.text "phrase", default: "", null: false
t.string "context", default: [], null: false, array: true
t.boolean "irreversible", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "whole_word", default: true, null: false
t.index ["account_id"], name: "index_custom_filters_on_account_id"
end
create_table "email_domain_blocks", force: :cascade do |t|
t.string "domain", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_follows_on_target_account_id"
end
create_table "group_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.boolean "write_permissions", default: false, null: false
t.string "role"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_accounts_on_group_id_and_account_id"
end
create_table "group_categories", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "text", default: "", null: false
end
create_table "group_join_requests", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "group_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_join_requests_on_account_id_and_group_id", unique: true
t.index ["group_id"], name: "index_group_join_requests_on_group_id"
end
create_table "group_pinned_statuses", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "group_id", null: false
t.index ["group_id"], name: "index_group_pinned_statuses_on_group_id"
t.index ["status_id", "group_id"], name: "index_group_pinned_statuses_on_status_id_and_group_id", unique: true
end
create_table "group_removed_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_removed_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_removed_accounts_on_group_id_and_account_id"
end
create_table "groups", force: :cascade do |t|
t.bigint "account_id"
t.string "title", null: false
t.string "description", null: false
t.string "cover_image_file_name"
t.string "cover_image_content_type"
t.integer "cover_image_file_size"
t.datetime "cover_image_updated_at"
t.boolean "is_nsfw", default: false, null: false
t.boolean "is_featured", default: false, null: false
t.boolean "is_archived", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "member_count", default: 0
t.text "slug"
t.boolean "is_private", default: false
t.boolean "is_visible", default: true
t.string "tags", default: [], array: true
t.string "password"
t.integer "group_category_id"
t.index ["account_id"], name: "index_groups_on_account_id"
t.index ["slug"], name: "index_groups_on_slug", unique: true
end
create_table "identities", force: :cascade do |t|
t.string "provider", default: "", null: false
t.string "uid", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id"
t.index ["user_id"], name: "index_identities_on_user_id"
end
create_table "link_blocks", force: :cascade do |t|
t.string "link", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["link"], name: "index_link_blocks_on_link", unique: true
end
create_table "list_accounts", force: :cascade do |t|
t.bigint "list_id", null: false
t.bigint "account_id", null: false
t.bigint "follow_id"
t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
t.index ["follow_id"], name: "index_list_accounts_on_follow_id"
t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
end
create_table "lists", force: :cascade do |t|
t.bigint "account_id", null: false
t.string "title", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_lists_on_account_id"
end
create_table "media_attachment_albums", force: :cascade do |t|
t.text "title", default: "", null: false
t.text "description"
t.integer "account_id", null: false
t.integer "visibility", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "cover_id"
t.integer "count", default: 0, null: false
t.index ["cover_id"], name: "index_media_attachment_albums_on_cover_id"
end
create_table "media_attachments", force: :cascade do |t|
t.bigint "status_id"
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.string "remote_url", default: "", null: false
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.bigint "scheduled_status_id"
t.string "blurhash"
t.bigint "media_attachment_album_id"
t.index ["account_id"], name: "index_media_attachments_on_account_id"
t.index ["media_attachment_album_id"], name: "index_media_attachments_on_media_attachment_album_id"
t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
t.index ["status_id"], name: "index_media_attachments_on_status_id"
t.index ["type"], name: "index_media_attachments_on_type"
end
create_table "mentions", force: :cascade do |t|
t.bigint "status_id"
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
create_table "mutes", force: :cascade do |t|
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
t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
end
create_table "notifications", force: :cascade do |t|
t.bigint "activity_id", null: false
t.string "activity_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "from_account_id", null: false
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
t.index ["account_id", "id"], name: "index_notifications_on_account_id_and_id", order: { id: :desc }
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
end
create_table "oauth_access_grants", force: :cascade do |t|
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 ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
end
create_table "oauth_access_tokens", force: :cascade do |t|
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
end
create_table "oauth_applications", force: :cascade do |t|
t.string "name", null: false
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
t.string "scopes", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "superapp", default: false, null: false
t.string "website"
t.string "owner_type"
t.bigint "owner_id"
t.boolean "confidential", default: true, null: false
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
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 "poll_votes", force: :cascade do |t|
t.bigint "account_id"
t.bigint "poll_id"
t.integer "choice", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.index ["account_id"], name: "index_poll_votes_on_account_id"
t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
end
create_table "polls", force: :cascade do |t|
t.bigint "account_id"
t.bigint "status_id"
t.datetime "expires_at"
t.string "options", default: [], null: false, array: true
t.bigint "cached_tallies", default: [], null: false, array: true
t.boolean "multiple", default: false, null: false
t.boolean "hide_totals", default: false, null: false
t.bigint "votes_count", default: 0, null: false
t.datetime "last_fetched_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lock_version", default: 0, null: false
t.index ["account_id"], name: "index_polls_on_account_id"
t.index ["created_at"], name: "index_polls_on_created_at"
t.index ["id", "lock_version"], name: "index_polls_on_id_and_lock_version"
t.index ["status_id"], name: "index_polls_on_status_id"
end
create_table "preview_cards", force: :cascade do |t|
t.string "url", default: "", null: false
t.string "title", default: "", null: false
t.string "description", default: "", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.integer "type", default: 0, null: false
t.text "html", default: "", null: false
t.string "author_name", default: "", null: false
t.string "author_url", default: "", null: false
t.string "provider_name", default: "", null: false
t.string "provider_url", default: "", null: false
t.integer "width", default: 0, null: false
t.integer "height", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "embed_url", default: "", null: false
t.index ["url"], name: "index_preview_cards_on_url", unique: true
end
create_table "preview_cards_statuses", id: false, force: :cascade do |t|
t.bigint "preview_card_id", null: false
t.bigint "status_id", null: false
t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
end
create_table "promotions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.bigint "status_id", null: false
t.string "timeline_id"
t.integer "position", default: 10
end
create_table "report_notes", force: :cascade do |t|
t.text "content", null: false
t.bigint "report_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_report_notes_on_account_id"
t.index ["report_id"], name: "index_report_notes_on_report_id"
end
create_table "reports", force: :cascade do |t|
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.bigint "assigned_account_id"
t.string "uri"
t.index ["account_id"], name: "index_reports_on_account_id"
t.index ["action_taken"], name: "index_reports_on_action_taken"
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
end
create_table "scheduled_statuses", force: :cascade do |t|
t.bigint "account_id"
t.datetime "scheduled_at"
t.jsonb "params"
t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
end
create_table "session_activations", force: :cascade do |t|
t.string "session_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, 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 ["access_token_id"], name: "index_session_activations_on_access_token_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"
end
create_table "settings", force: :cascade do |t|
t.string "var", null: false
t.text "value"
t.string "thing_type"
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
create_table "shortcuts", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "shortcut_id", null: false
t.string "shortcut_type", default: "", null: false
t.index ["account_id", "shortcut_id", "shortcut_type"], name: "index_shortcuts_on_account_id_and_shortcut_id_and_shortcut_type", unique: true
end
create_table "site_uploads", force: :cascade do |t|
t.string "var", default: "", null: false
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.json "meta"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["var"], name: "index_site_uploads_on_var", unique: true
end
create_table "status_bookmark_collections", force: :cascade do |t|
t.text "title", default: "", null: false
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "status_bookmarks", 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.bigint "status_bookmark_collection_id"
t.index ["account_id", "status_id"], name: "index_status_bookmarks_on_account_id_and_status_id", unique: true
t.index ["status_bookmark_collection_id"], name: "index_status_bookmarks_on_status_bookmark_collection_id"
t.index ["status_id"], name: "index_status_bookmarks_on_status_id"
end
create_table "status_pins", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "status_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, null: false
t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
end
create_table "status_revisions", force: :cascade do |t|
t.bigint "status_id"
t.string "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["status_id"], name: "index_status_revisions_on_status_id"
end
create_table "status_stats", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "replies_count", default: 0, null: false
t.bigint "reblogs_count", default: 0, null: false
t.bigint "favourites_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["created_at"], name: "index_status_stats_on_created_at"
t.index ["favourites_count"], name: "index_status_stats_on_favourites_count"
t.index ["reblogs_count"], name: "index_status_stats_on_reblogs_count"
t.index ["replies_count"], name: "index_status_stats_on_replies_count"
t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
t.index ["updated_at"], name: "index_status_stats_on_updated_at"
end
create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
t.string "uri"
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "in_reply_to_id"
t.bigint "reblog_of_id"
t.string "url"
t.boolean "sensitive", default: false, null: false
t.integer "visibility", default: 0, null: false
t.text "spoiler_text", default: "", null: false
t.boolean "reply", default: false, null: false
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.bigint "poll_id"
t.integer "group_id"
t.bigint "quote_of_id"
t.datetime "revised_at"
t.text "markdown"
t.datetime "expires_at"
t.boolean "has_quote"
t.index ["account_id", "id", "visibility", "created_at"], name: "index_statuses_20201206", order: { id: :desc }
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
t.index ["created_at", "reply", "reblog_of_id", "account_id", "group_id"], name: "index_statuses_on_created_at_desc_account", order: { created_at: :desc }
t.index ["created_at", "reply", "reblog_of_id"], name: "index_statuses_on_created_at_desc_account_id", order: { created_at: :desc }
t.index ["created_at"], name: "index_statuses_on_created_at"
t.index ["group_id", "reply", "reblog_of_id", "account_id"], name: "index_statuses_group_id_reply"
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
t.index ["quote_of_id"], name: "index_statuses_on_quote_of_id"
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
t.index ["reply"], name: "index_statuses_on_reply"
t.index ["updated_at"], name: "index_statuses_on_updated_at"
t.index ["uri"], name: "index_statuses_on_uri", unique: true
end
create_table "statuses_tags", id: false, force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "tag_id", null: false
t.index ["status_id"], name: "index_statuses_tags_on_status_id"
t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
end
create_table "tags", force: :cascade do |t|
t.string "name", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text) text_pattern_ops", name: "hashtag_search_index"
t.index ["name"], name: "index_tags_on_name", unique: true
end
create_table "tombstones", force: :cascade do |t|
t.bigint "account_id"
t.string "uri", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "by_moderator"
t.index ["account_id"], name: "index_tombstones_on_account_id"
t.index ["uri"], name: "index_tombstones_on_uri"
end
create_table "transactions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "payment_type"
t.string "provider_type"
t.text "provider_response"
t.integer "amount", null: false
t.boolean "success", default: false, null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.boolean "admin", default: false, null: false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.string "locale"
t.string "encrypted_otp_secret"
t.string "encrypted_otp_secret_iv"
t.string "encrypted_otp_secret_salt"
t.integer "consumed_timestep"
t.boolean "otp_required_for_login", default: false, null: false
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.boolean "disabled", default: false, null: false
t.boolean "moderator", default: false, null: false
t.string "remember_token"
t.string "chosen_languages", array: true
t.bigint "created_by_application_id"
t.boolean "approved", default: true, null: false
t.bigint "last_read_notification"
t.string "unique_email"
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["created_at"], name: "index_users_on_created_at"
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
t.index ["current_sign_in_at"], name: "index_users_on_current_sign_in_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["remember_token"], name: "index_users_on_remember_token"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unique_email"], name: "index_users_on_unique_email"
end
create_table "web_push_subscriptions", force: :cascade do |t|
t.string "endpoint", null: false
t.string "key_p256dh", null: false
t.string "key_auth", null: false
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "access_token_id"
t.bigint "user_id"
t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id"
t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
end
create_table "web_settings", force: :cascade do |t|
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
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_moderation_notes", "accounts"
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
add_foreign_key "account_stats", "accounts", on_delete: :cascade
add_foreign_key "account_tag_stats", "tags", on_delete: :cascade
add_foreign_key "account_username_changes", "accounts", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", on_delete: :nullify
add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
add_foreign_key "backups", "users", on_delete: :nullify
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 "chat_blocks", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "chat_blocks", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_conversations", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_messages", column: "last_chat_message_id", on_delete: :nullify
add_foreign_key "chat_messages", "accounts", column: "from_account_id", on_delete: :cascade
add_foreign_key "chat_messages", "chat_conversations", on_delete: :cascade
add_foreign_key "custom_filters", "accounts", on_delete: :cascade
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 "group_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_accounts", "groups", on_delete: :cascade
add_foreign_key "group_join_requests", "accounts", on_delete: :cascade
add_foreign_key "group_join_requests", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "statuses", on_delete: :cascade
add_foreign_key "group_removed_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_removed_accounts", "groups", on_delete: :cascade
add_foreign_key "groups", "group_categories", on_delete: :nullify
add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
add_foreign_key "list_accounts", "accounts", on_delete: :cascade
add_foreign_key "list_accounts", "follows", on_delete: :cascade
add_foreign_key "list_accounts", "lists", on_delete: :cascade
add_foreign_key "lists", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "media_attachments", column: "cover_id", on_delete: :nullify
add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
add_foreign_key "media_attachments", "media_attachment_albums", on_delete: :nullify
add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
add_foreign_key "media_attachments", "statuses", on_delete: :nullify
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", 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 "poll_votes", "accounts", on_delete: :cascade
add_foreign_key "poll_votes", "polls", on_delete: :cascade
add_foreign_key "polls", "accounts", on_delete: :cascade
add_foreign_key "polls", "statuses", on_delete: :cascade
add_foreign_key "report_notes", "accounts", on_delete: :cascade
add_foreign_key "report_notes", "reports", 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: "assigned_account_id", 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 "scheduled_statuses", "accounts", 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 "shortcuts", "accounts", on_delete: :cascade
add_foreign_key "status_bookmark_collections", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "status_bookmark_collections", on_delete: :nullify
add_foreign_key "status_bookmarks", "statuses", 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 "status_stats", "statuses", 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", "groups", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "quote_of_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", name: "fk_3081861e21", on_delete: :cascade
add_foreign_key "tombstones", "accounts", on_delete: :cascade
add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
end

977
db/slave2_schema.rb Normal file
View File

@ -0,0 +1,977 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_01_23_050026) do
# These are extensions that must be enabled in order to support this database
enable_extension "hypopg"
enable_extension "pg_stat_statements"
enable_extension "pgstattuple"
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 ["conversation_id"], name: "index_account_conversations_on_conversation_id"
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 "account_stats", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "statuses_count", default: 0, null: false
t.bigint "following_count", default: 0, null: false
t.bigint "followers_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "last_status_at"
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
end
create_table "account_tag_stats", force: :cascade do |t|
t.bigint "tag_id", null: false
t.bigint "accounts_count", default: 0, null: false
t.boolean "hidden", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["tag_id"], name: "index_account_tag_stats_on_tag_id", unique: true
end
create_table "account_username_changes", force: :cascade do |t|
t.bigint "account_id", null: false
t.text "from_username", default: "", null: false
t.text "to_username", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_username_changes_on_account_id"
end
create_table "account_verification_requests", force: :cascade do |t|
t.bigint "account_id"
t.string "image_file_name"
t.string "image_content_type"
t.bigint "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_verification_requests_on_account_id"
end
create_table "account_warning_presets", force: :cascade do |t|
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "account_warnings", force: :cascade do |t|
t.bigint "account_id"
t.bigint "target_account_id"
t.integer "action", default: 0, null: false
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_account_warnings_on_account_id"
t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
end
create_table "accounts", force: :cascade do |t|
t.string "username", default: "", null: false
t.string "domain"
t.string "secret", default: "", null: false
t.text "private_key"
t.text "public_key", default: "", null: false
t.string "remote_url", default: "", null: false
t.string "salmon_url", default: "", null: false
t.string "hub_url", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "note", default: "", null: false
t.string "display_name", default: "", null: false
t.string "uri", default: "", null: false
t.string "url"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.string "header_file_name"
t.string "header_content_type"
t.integer "header_file_size"
t.datetime "header_updated_at"
t.string "avatar_remote_url"
t.datetime "subscription_expires_at"
t.boolean "locked", default: false, null: false
t.string "header_remote_url", default: "", null: false
t.datetime "last_webfingered_at"
t.string "inbox_url", default: "", null: false
t.string "outbox_url", default: "", null: false
t.string "shared_inbox_url", default: "", null: false
t.string "followers_url", default: "", null: false
t.integer "protocol", default: 0, null: false
t.boolean "memorial", default: false, null: false
t.bigint "moved_to_account_id"
t.string "featured_collection_url"
t.jsonb "fields"
t.string "actor_type"
t.boolean "discoverable"
t.string "also_known_as", array: true
t.datetime "silenced_at"
t.datetime "suspended_at"
t.boolean "is_pro", default: false, null: false
t.datetime "pro_expires_at"
t.boolean "is_verified", default: false, null: false
t.boolean "is_donor", default: false, null: false
t.boolean "is_investor", default: false, null: false
t.boolean "is_flagged_as_spam", default: false, null: false
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
t.index ["domain"], name: "index_accounts_on_domain"
t.index ["is_donor"], name: "index_accounts_on_is_donor"
t.index ["is_investor"], name: "index_accounts_on_is_investor"
t.index ["is_pro"], name: "index_accounts_on_is_pro"
t.index ["is_verified"], name: "index_accounts_on_is_verified"
t.index ["locked"], name: "index_accounts_on_locked"
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
t.index ["uri"], name: "index_accounts_on_uri"
t.index ["url"], name: "index_accounts_on_url"
end
create_table "accounts_tags", id: false, force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "tag_id", null: false
t.index ["account_id", "tag_id"], name: "index_accounts_tags_on_account_id_and_tag_id"
t.index ["tag_id", "account_id"], name: "index_accounts_tags_on_tag_id_and_account_id", unique: true
end
create_table "admin_action_logs", force: :cascade do |t|
t.bigint "account_id"
t.string "action", default: "", null: false
t.string "target_type"
t.bigint "target_id"
t.text "recorded_changes", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_admin_action_logs_on_account_id"
t.index ["target_type", "target_id"], name: "index_admin_action_logs_on_target_type_and_target_id"
end
create_table "backups", force: :cascade do |t|
t.bigint "user_id"
t.string "dump_file_name"
t.string "dump_content_type"
t.integer "dump_file_size"
t.datetime "dump_updated_at"
t.boolean "processed", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "blocks", force: :cascade do |t|
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.string "uri"
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
end
create_table "btc_payments", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "btcpay_invoice_id", null: false
t.string "plan", null: false
t.boolean "success", default: false, null: false
end
create_table "chat_blocks", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "target_account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "target_account_id"], name: "index_chat_blocks_on_account_id_and_target_account_id", unique: true
end
create_table "chat_conversation_accounts", force: :cascade do |t|
t.bigint "account_id"
t.bigint "chat_conversation_id"
t.bigint "participant_account_ids", default: [], null: false, array: true
t.bigint "last_chat_message_id"
t.boolean "is_hidden", default: false, null: false
t.boolean "is_approved", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "unread_count", default: 0
t.string "chat_message_expiration_policy"
t.boolean "is_muted", default: false, null: false
t.index ["account_id"], name: "index_chat_conversation_accounts_on_account_id"
t.index ["chat_conversation_id"], name: "index_chat_conversation_accounts_on_chat_conversation_id"
end
create_table "chat_conversations", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "chat_messages", force: :cascade do |t|
t.text "text", default: "", null: false
t.text "language", default: "", null: false
t.integer "from_account_id", null: false
t.integer "chat_conversation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.index ["from_account_id", "chat_conversation_id"], name: "index_chat_messages_on_from_account_id_and_chat_conversation_id"
end
create_table "conversations", force: :cascade do |t|
t.string "uri"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["uri"], name: "index_conversations_on_uri", unique: true
end
create_table "custom_emojis", force: :cascade do |t|
t.string "shortcode", default: "", null: false
t.string "domain"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.string "image_remote_url"
t.boolean "visible_in_picker", default: true, null: false
t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
end
create_table "custom_filters", force: :cascade do |t|
t.bigint "account_id"
t.datetime "expires_at"
t.text "phrase", default: "", null: false
t.string "context", default: [], null: false, array: true
t.boolean "irreversible", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "whole_word", default: true, null: false
t.index ["account_id"], name: "index_custom_filters_on_account_id"
end
create_table "email_domain_blocks", force: :cascade do |t|
t.string "domain", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
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.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.boolean "show_reblogs", default: true, null: false
t.string "uri"
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_follows_on_target_account_id"
end
create_table "group_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.boolean "write_permissions", default: false, null: false
t.string "role"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_accounts_on_group_id_and_account_id"
end
create_table "group_categories", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "text", default: "", null: false
end
create_table "group_join_requests", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "group_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_join_requests_on_account_id_and_group_id", unique: true
t.index ["group_id"], name: "index_group_join_requests_on_group_id"
end
create_table "group_pinned_statuses", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "group_id", null: false
t.index ["group_id"], name: "index_group_pinned_statuses_on_group_id"
t.index ["status_id", "group_id"], name: "index_group_pinned_statuses_on_status_id_and_group_id", unique: true
end
create_table "group_removed_accounts", force: :cascade do |t|
t.bigint "group_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "group_id"], name: "index_group_removed_accounts_on_account_id_and_group_id", unique: true
t.index ["group_id", "account_id"], name: "index_group_removed_accounts_on_group_id_and_account_id"
end
create_table "groups", force: :cascade do |t|
t.bigint "account_id"
t.string "title", null: false
t.string "description", null: false
t.string "cover_image_file_name"
t.string "cover_image_content_type"
t.integer "cover_image_file_size"
t.datetime "cover_image_updated_at"
t.boolean "is_nsfw", default: false, null: false
t.boolean "is_featured", default: false, null: false
t.boolean "is_archived", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "member_count", default: 0
t.text "slug"
t.boolean "is_private", default: false
t.boolean "is_visible", default: true
t.string "tags", default: [], array: true
t.string "password"
t.integer "group_category_id"
t.index ["account_id"], name: "index_groups_on_account_id"
t.index ["slug"], name: "index_groups_on_slug", unique: true
end
create_table "identities", force: :cascade do |t|
t.string "provider", default: "", null: false
t.string "uid", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id"
t.index ["user_id"], name: "index_identities_on_user_id"
end
create_table "link_blocks", force: :cascade do |t|
t.string "link", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["link"], name: "index_link_blocks_on_link", unique: true
end
create_table "list_accounts", force: :cascade do |t|
t.bigint "list_id", null: false
t.bigint "account_id", null: false
t.bigint "follow_id"
t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
t.index ["follow_id"], name: "index_list_accounts_on_follow_id"
t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
end
create_table "lists", force: :cascade do |t|
t.bigint "account_id", null: false
t.string "title", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_lists_on_account_id"
end
create_table "media_attachment_albums", force: :cascade do |t|
t.text "title", default: "", null: false
t.text "description"
t.integer "account_id", null: false
t.integer "visibility", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "cover_id"
t.integer "count", default: 0, null: false
t.index ["cover_id"], name: "index_media_attachment_albums_on_cover_id"
end
create_table "media_attachments", force: :cascade do |t|
t.bigint "status_id"
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.string "remote_url", default: "", null: false
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.bigint "scheduled_status_id"
t.string "blurhash"
t.bigint "media_attachment_album_id"
t.index ["account_id"], name: "index_media_attachments_on_account_id"
t.index ["media_attachment_album_id"], name: "index_media_attachments_on_media_attachment_album_id"
t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
t.index ["status_id"], name: "index_media_attachments_on_status_id"
t.index ["type"], name: "index_media_attachments_on_type"
end
create_table "mentions", force: :cascade do |t|
t.bigint "status_id"
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
create_table "mutes", force: :cascade do |t|
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
t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
end
create_table "notifications", force: :cascade do |t|
t.bigint "activity_id", null: false
t.string "activity_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "from_account_id", null: false
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
t.index ["account_id", "id"], name: "index_notifications_on_account_id_and_id", order: { id: :desc }
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
end
create_table "oauth_access_grants", force: :cascade do |t|
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 ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
end
create_table "oauth_access_tokens", force: :cascade do |t|
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
end
create_table "oauth_applications", force: :cascade do |t|
t.string "name", null: false
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
t.string "scopes", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "superapp", default: false, null: false
t.string "website"
t.string "owner_type"
t.bigint "owner_id"
t.boolean "confidential", default: true, null: false
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
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 "poll_votes", force: :cascade do |t|
t.bigint "account_id"
t.bigint "poll_id"
t.integer "choice", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uri"
t.index ["account_id"], name: "index_poll_votes_on_account_id"
t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
end
create_table "polls", force: :cascade do |t|
t.bigint "account_id"
t.bigint "status_id"
t.datetime "expires_at"
t.string "options", default: [], null: false, array: true
t.bigint "cached_tallies", default: [], null: false, array: true
t.boolean "multiple", default: false, null: false
t.boolean "hide_totals", default: false, null: false
t.bigint "votes_count", default: 0, null: false
t.datetime "last_fetched_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lock_version", default: 0, null: false
t.index ["account_id"], name: "index_polls_on_account_id"
t.index ["created_at"], name: "index_polls_on_created_at"
t.index ["id", "lock_version"], name: "index_polls_on_id_and_lock_version"
t.index ["status_id"], name: "index_polls_on_status_id"
end
create_table "preview_cards", force: :cascade do |t|
t.string "url", default: "", null: false
t.string "title", default: "", null: false
t.string "description", default: "", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.integer "type", default: 0, null: false
t.text "html", default: "", null: false
t.string "author_name", default: "", null: false
t.string "author_url", default: "", null: false
t.string "provider_name", default: "", null: false
t.string "provider_url", default: "", null: false
t.integer "width", default: 0, null: false
t.integer "height", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "embed_url", default: "", null: false
t.index ["url"], name: "index_preview_cards_on_url", unique: true
end
create_table "preview_cards_statuses", id: false, force: :cascade do |t|
t.bigint "preview_card_id", null: false
t.bigint "status_id", null: false
t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
end
create_table "promotions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.bigint "status_id", null: false
t.string "timeline_id"
t.integer "position", default: 10
end
create_table "report_notes", force: :cascade do |t|
t.text "content", null: false
t.bigint "report_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_report_notes_on_account_id"
t.index ["report_id"], name: "index_report_notes_on_report_id"
end
create_table "reports", force: :cascade do |t|
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.bigint "assigned_account_id"
t.string "uri"
t.index ["account_id"], name: "index_reports_on_account_id"
t.index ["action_taken"], name: "index_reports_on_action_taken"
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
end
create_table "scheduled_statuses", force: :cascade do |t|
t.bigint "account_id"
t.datetime "scheduled_at"
t.jsonb "params"
t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
end
create_table "session_activations", force: :cascade do |t|
t.string "session_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, 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 ["access_token_id"], name: "index_session_activations_on_access_token_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"
end
create_table "settings", force: :cascade do |t|
t.string "var", null: false
t.text "value"
t.string "thing_type"
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
create_table "shortcuts", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
t.bigint "shortcut_id", null: false
t.string "shortcut_type", default: "", null: false
t.index ["account_id", "shortcut_id", "shortcut_type"], name: "index_shortcuts_on_account_id_and_shortcut_id_and_shortcut_type", unique: true
end
create_table "site_uploads", force: :cascade do |t|
t.string "var", default: "", null: false
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.json "meta"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["var"], name: "index_site_uploads_on_var", unique: true
end
create_table "status_bookmark_collections", force: :cascade do |t|
t.text "title", default: "", null: false
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "status_bookmarks", 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.bigint "status_bookmark_collection_id"
t.index ["account_id", "status_id"], name: "index_status_bookmarks_on_account_id_and_status_id", unique: true
t.index ["status_bookmark_collection_id"], name: "index_status_bookmarks_on_status_bookmark_collection_id"
t.index ["status_id"], name: "index_status_bookmarks_on_status_id"
end
create_table "status_pins", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "status_id", null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, null: false
t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
end
create_table "status_revisions", force: :cascade do |t|
t.bigint "status_id"
t.string "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["status_id"], name: "index_status_revisions_on_status_id"
end
create_table "status_stats", force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "replies_count", default: 0, null: false
t.bigint "reblogs_count", default: 0, null: false
t.bigint "favourites_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["created_at"], name: "index_status_stats_on_created_at"
t.index ["favourites_count"], name: "index_status_stats_on_favourites_count"
t.index ["reblogs_count"], name: "index_status_stats_on_reblogs_count"
t.index ["replies_count"], name: "index_status_stats_on_replies_count"
t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
t.index ["updated_at"], name: "index_status_stats_on_updated_at"
end
create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
t.string "uri"
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "in_reply_to_id"
t.bigint "reblog_of_id"
t.string "url"
t.boolean "sensitive", default: false, null: false
t.integer "visibility", default: 0, null: false
t.text "spoiler_text", default: "", null: false
t.boolean "reply", default: false, null: false
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.bigint "poll_id"
t.integer "group_id"
t.bigint "quote_of_id"
t.datetime "revised_at"
t.text "markdown"
t.datetime "expires_at"
t.boolean "has_quote"
t.index ["account_id", "id", "visibility", "created_at"], name: "index_statuses_20201206", order: { id: :desc }
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
t.index ["created_at", "reply", "reblog_of_id", "account_id", "group_id"], name: "index_statuses_on_created_at_desc_account", order: { created_at: :desc }
t.index ["created_at", "reply", "reblog_of_id"], name: "index_statuses_on_created_at_desc_account_id", order: { created_at: :desc }
t.index ["created_at"], name: "index_statuses_on_created_at"
t.index ["group_id", "reply", "reblog_of_id", "account_id"], name: "index_statuses_group_id_reply"
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
t.index ["quote_of_id"], name: "index_statuses_on_quote_of_id"
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
t.index ["reply"], name: "index_statuses_on_reply"
t.index ["updated_at"], name: "index_statuses_on_updated_at"
t.index ["uri"], name: "index_statuses_on_uri", unique: true
end
create_table "statuses_tags", id: false, force: :cascade do |t|
t.bigint "status_id", null: false
t.bigint "tag_id", null: false
t.index ["status_id"], name: "index_statuses_tags_on_status_id"
t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
end
create_table "tags", force: :cascade do |t|
t.string "name", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text) text_pattern_ops", name: "hashtag_search_index"
t.index ["name"], name: "index_tags_on_name", unique: true
end
create_table "tombstones", force: :cascade do |t|
t.bigint "account_id"
t.string "uri", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "by_moderator"
t.index ["account_id"], name: "index_tombstones_on_account_id"
t.index ["uri"], name: "index_tombstones_on_uri"
end
create_table "transactions", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id", null: false
t.string "payment_type"
t.string "provider_type"
t.text "provider_response"
t.integer "amount", null: false
t.boolean "success", default: false, null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.boolean "admin", default: false, null: false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.string "locale"
t.string "encrypted_otp_secret"
t.string "encrypted_otp_secret_iv"
t.string "encrypted_otp_secret_salt"
t.integer "consumed_timestep"
t.boolean "otp_required_for_login", default: false, null: false
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.boolean "disabled", default: false, null: false
t.boolean "moderator", default: false, null: false
t.string "remember_token"
t.string "chosen_languages", array: true
t.bigint "created_by_application_id"
t.boolean "approved", default: true, null: false
t.bigint "last_read_notification"
t.string "unique_email"
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["created_at"], name: "index_users_on_created_at"
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
t.index ["current_sign_in_at"], name: "index_users_on_current_sign_in_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["remember_token"], name: "index_users_on_remember_token"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unique_email"], name: "index_users_on_unique_email"
end
create_table "web_push_subscriptions", force: :cascade do |t|
t.string "endpoint", null: false
t.string "key_p256dh", null: false
t.string "key_auth", null: false
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "access_token_id"
t.bigint "user_id"
t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id"
t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
end
create_table "web_settings", force: :cascade do |t|
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
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_moderation_notes", "accounts"
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
add_foreign_key "account_stats", "accounts", on_delete: :cascade
add_foreign_key "account_tag_stats", "tags", on_delete: :cascade
add_foreign_key "account_username_changes", "accounts", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", on_delete: :nullify
add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
add_foreign_key "backups", "users", on_delete: :nullify
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 "chat_blocks", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "chat_blocks", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "accounts", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_conversations", on_delete: :cascade
add_foreign_key "chat_conversation_accounts", "chat_messages", column: "last_chat_message_id", on_delete: :nullify
add_foreign_key "chat_messages", "accounts", column: "from_account_id", on_delete: :cascade
add_foreign_key "chat_messages", "chat_conversations", on_delete: :cascade
add_foreign_key "custom_filters", "accounts", on_delete: :cascade
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 "group_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_accounts", "groups", on_delete: :cascade
add_foreign_key "group_join_requests", "accounts", on_delete: :cascade
add_foreign_key "group_join_requests", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "groups", on_delete: :cascade
add_foreign_key "group_pinned_statuses", "statuses", on_delete: :cascade
add_foreign_key "group_removed_accounts", "accounts", on_delete: :cascade
add_foreign_key "group_removed_accounts", "groups", on_delete: :cascade
add_foreign_key "groups", "group_categories", on_delete: :nullify
add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
add_foreign_key "list_accounts", "accounts", on_delete: :cascade
add_foreign_key "list_accounts", "follows", on_delete: :cascade
add_foreign_key "list_accounts", "lists", on_delete: :cascade
add_foreign_key "lists", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "accounts", on_delete: :cascade
add_foreign_key "media_attachment_albums", "media_attachments", column: "cover_id", on_delete: :nullify
add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
add_foreign_key "media_attachments", "media_attachment_albums", on_delete: :nullify
add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
add_foreign_key "media_attachments", "statuses", on_delete: :nullify
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", 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 "poll_votes", "accounts", on_delete: :cascade
add_foreign_key "poll_votes", "polls", on_delete: :cascade
add_foreign_key "polls", "accounts", on_delete: :cascade
add_foreign_key "polls", "statuses", on_delete: :cascade
add_foreign_key "report_notes", "accounts", on_delete: :cascade
add_foreign_key "report_notes", "reports", 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: "assigned_account_id", 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 "scheduled_statuses", "accounts", 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 "shortcuts", "accounts", on_delete: :cascade
add_foreign_key "status_bookmark_collections", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "accounts", on_delete: :cascade
add_foreign_key "status_bookmarks", "status_bookmark_collections", on_delete: :nullify
add_foreign_key "status_bookmarks", "statuses", 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 "status_stats", "statuses", 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", "groups", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
add_foreign_key "statuses", "statuses", column: "quote_of_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", name: "fk_3081861e21", on_delete: :cascade
add_foreign_key "tombstones", "accounts", on_delete: :cascade
add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
end