diff --git a/Gemfile b/Gemfile index 20c7a4d3..6d3c4281 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,6 @@ gem 'thor', '~> 0.20' gem 'hamlit-rails', '~> 0.2' gem 'pg', '~> 1.2.3' -gem 'makara', '~> 0.4' gem 'pghero', '~> 2.7.0' gem 'dotenv-rails', '~> 2.7' diff --git a/Gemfile.lock b/Gemfile.lock index 43ac082f..35b7fe0e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -360,8 +360,6 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - makara (0.5.0) - activerecord (>= 3.0.0) marcel (0.3.3) mimemagic (~> 0.3.2) mario-redis-lock (1.2.1) @@ -728,7 +726,6 @@ DEPENDENCIES link_header (~> 0.0) listen lograge (~> 0.11) - makara (~> 0.4) mario-redis-lock (~> 1.2) memory_profiler microformats (~> 4.1) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 84954d1c..74c2a607 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -65,7 +65,11 @@ class Api::BaseController < ApplicationController def current_resource_owner if doorkeeper_token @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 return @current_user diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index 8db23cd2..6ba93e3d 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -22,11 +22,17 @@ class Api::V1::Accounts::StatusesController < Api::BaseController private def set_account - @account = Account.find(params[:account_id]) + ActiveRecord::Base.connected_to(role: :reading) do + @account = Account.find(params[:account_id]) + end end def load_statuses - cached_account_statuses + cas = nil + ActiveRecord::Base.connected_to(role: :reading) do + cas = cached_account_statuses + end + cas end def cached_account_statuses diff --git a/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb b/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb index 6f56912e..a4d4676f 100644 --- a/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb +++ b/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb @@ -17,7 +17,11 @@ class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController private def load_statuses - cached_bookmarks + cb = nil + ActiveRecord::Base.connected_to(role: :reading) do + cb = cached_bookmarks + end + cb end def cached_bookmarks @@ -25,7 +29,7 @@ class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController Status.reorder(nil).joins(:status_bookmarks).merge(results), Status ) - end + `` end def results @_results ||= account_bookmarks.paginate_by_id( @@ -65,4 +69,4 @@ class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController def pagination_params(core_params) params.slice(:limit).permit(:limit).merge(core_params) end -end \ No newline at end of file +end diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index cb3268c6..f995c17a 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -27,7 +27,6 @@ class Api::V1::NotificationsController < Api::BaseController def mark_read if !params[:id].nil? and !current_account.user.nil? 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}" end # current_account.notifications.find(params[:id]).mark_read! diff --git a/app/controllers/api/v1/statuses/favourites_controller.rb b/app/controllers/api/v1/statuses/favourites_controller.rb index 3bc2cc49..96582d6d 100644 --- a/app/controllers/api/v1/statuses/favourites_controller.rb +++ b/app/controllers/api/v1/statuses/favourites_controller.rb @@ -34,14 +34,6 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController end def requested_status - rs = nil - 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 + Status.find(params[:status_id]) end end diff --git a/app/controllers/api/v1/statuses/reblogs_controller.rb b/app/controllers/api/v1/statuses/reblogs_controller.rb index a05ada84..4dfc5c32 100644 --- a/app/controllers/api/v1/statuses/reblogs_controller.rb +++ b/app/controllers/api/v1/statuses/reblogs_controller.rb @@ -31,15 +31,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController private def status_for_reblog - rs = nil - 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 + Status.find(params[:status_id]) end def status_for_destroy diff --git a/app/controllers/api/v1/timelines/explore_controller.rb b/app/controllers/api/v1/timelines/explore_controller.rb index 52af419d..621eedbc 100644 --- a/app/controllers/api/v1/timelines/explore_controller.rb +++ b/app/controllers/api/v1/timelines/explore_controller.rb @@ -39,7 +39,11 @@ class Api::V1::Timelines::ExploreController < Api::BaseController end 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 def explore_statuses diff --git a/app/controllers/api/v1/timelines/group_collection_controller.rb b/app/controllers/api/v1/timelines/group_collection_controller.rb index cae00bf6..8c37ca34 100644 --- a/app/controllers/api/v1/timelines/group_collection_controller.rb +++ b/app/controllers/api/v1/timelines/group_collection_controller.rb @@ -56,7 +56,11 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController end 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 def group_collection_statuses diff --git a/app/controllers/api/v1/timelines/group_controller.rb b/app/controllers/api/v1/timelines/group_controller.rb index 4bf9290b..595e8627 100644 --- a/app/controllers/api/v1/timelines/group_controller.rb +++ b/app/controllers/api/v1/timelines/group_controller.rb @@ -46,7 +46,11 @@ class Api::V1::Timelines::GroupController < Api::BaseController end 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 def group_statuses diff --git a/app/controllers/api/v1/timelines/pro_controller.rb b/app/controllers/api/v1/timelines/pro_controller.rb index 97691a88..d26563b0 100644 --- a/app/controllers/api/v1/timelines/pro_controller.rb +++ b/app/controllers/api/v1/timelines/pro_controller.rb @@ -16,7 +16,11 @@ class Api::V1::Timelines::ProController < Api::BaseController end 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 def pro_statuses diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 47d767e2..8fe15855 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -89,8 +89,12 @@ class ApplicationController < ActionController::Base def current_session return nil if cookies.signed['_session_id'].nil? - @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']) + @current_session ||= Rails.cache.fetch("dk:sess:#{cookies.signed['_session_id']}", expires_in: 25.hours) do + sa = nil + ActiveRecord::Base.connected_to(role: :writing) do + sa = SessionActivation.find_by(session_id: cookies.signed['_session_id']) + end + sa end end diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 68471ce7..686e154c 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -10,7 +10,6 @@ class Auth::SessionsController < Devise::SessionsController prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create] before_action :set_instance_presenter, only: [:new] before_action :set_body_classes - before_action :use_master def new Devise.omniauth_configs.each do |provider, config| @@ -36,10 +35,6 @@ class Auth::SessionsController < Devise::SessionsController protected - def use_master - User.connection.stick_to_master! - end - def find_user if session[:otp_user_id] User.find(session[:otp_user_id]) diff --git a/app/controllers/concerns/session_tracking_concern.rb b/app/controllers/concerns/session_tracking_concern.rb index 26e2a9c8..9c2cd610 100644 --- a/app/controllers/concerns/session_tracking_concern.rb +++ b/app/controllers/concerns/session_tracking_concern.rb @@ -13,9 +13,10 @@ module SessionTrackingConcern def set_session_activity return unless session_needs_update? - conn = ActiveRecord::Base.connection - conn.stick_to_master! - conn.exec_query "update session_activations set updated_at = NOW() where id = #{current_session.id}" + ActiveRecord::Base.connected_to(role: :writing) do + conn = ActiveRecord::Base.connection + conn.exec_query "update session_activations set updated_at = NOW() where id = #{current_session.id}" + end end def session_needs_update? diff --git a/app/controllers/concerns/user_tracking_concern.rb b/app/controllers/concerns/user_tracking_concern.rb index 160f0de3..bef5cb07 100644 --- a/app/controllers/concerns/user_tracking_concern.rb +++ b/app/controllers/concerns/user_tracking_concern.rb @@ -12,7 +12,9 @@ module UserTrackingConcern private def set_user_activity - current_user.update_sign_in!(request) if user_needs_sign_in_update? + ActiveRecord::Base.connected_to(role: :writing) do + current_user.update_sign_in!(request) if user_needs_sign_in_update? + end end def user_needs_sign_in_update? diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb index bb5d639c..6c02c039 100644 --- a/app/controllers/oauth/authorizations_controller.rb +++ b/app/controllers/oauth/authorizations_controller.rb @@ -9,6 +9,9 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController include Localized + include ForceDbWriterRole + around_action :force_writer_db_role, only: [:store_current_location, :render_success] + private def store_current_location diff --git a/app/controllers/oauth/tokens_controller.rb b/app/controllers/oauth/tokens_controller.rb index fa6d58f2..0725b412 100644 --- a/app/controllers/oauth/tokens_controller.rb +++ b/app/controllers/oauth/tokens_controller.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true class Oauth::TokensController < Doorkeeper::TokensController + include ForceDbWriterRole + around_action :force_writer_db_role, only: :revoke + def revoke unsubscribe_for_token if authorized? && token.accessible? super diff --git a/app/controllers/react_controller.rb b/app/controllers/react_controller.rb index 52e334ba..98d84beb 100644 --- a/app/controllers/react_controller.rb +++ b/app/controllers/react_controller.rb @@ -17,16 +17,16 @@ class ReactController < ApplicationController before_action :set_instance_presenter def react - # + # end - + def groupBySlug @group = Group.where(slug: params[:groupSlug], is_archived: false).first unless @group.nil? return redirect_to "/groups/#{@group.id}" end - return not_found + return not_found end def status_show @@ -62,7 +62,7 @@ class ReactController < ApplicationController def redirect_to_original if @status.reblog? - redirect_to ::TagManager.instance.url_for(@status.reblog) + redirect_to ::TagManager.instance.url_for(@status.reblog) end end @@ -75,7 +75,7 @@ class ReactController < ApplicationController elsif find_public_route_matches return elsif request.path.count("/") == 1 && request.path.length === 1 - # + # elsif request.path.count("/") == 1 && !request.path.include?("@") acctFromPath = request.path.sub("/", "") @account = Account.find_local!(acctFromPath) @@ -108,14 +108,14 @@ class ReactController < ApplicationController end def initial_state_params - if !current_user.nil? + if !current_user.nil? && !current_session.nil? { settings: Web::Setting.find_by(user: current_user)&.data || {}, push_subscription: current_account.user.web_push_subscription(current_session), current_account: current_account, token: current_session.token, } - else + else return {} end end diff --git a/app/lib/force_db_writer_role.rb b/app/lib/force_db_writer_role.rb new file mode 100644 index 00000000..d97f2942 --- /dev/null +++ b/app/lib/force_db_writer_role.rb @@ -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 diff --git a/app/models/account.rb b/app/models/account.rb index 70533165..2fb330c0 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,6 +3,7 @@ # # Table name: accounts # +# id :bigint(8) not null, primary key # username :string default(""), not null # domain :string # secret :string default(""), not null @@ -19,11 +20,11 @@ # url :string # avatar_file_name :string # avatar_content_type :string -# avatar_file_size :bigint(8) +# avatar_file_size :integer # avatar_updated_at :datetime # header_file_name :string # header_content_type :string -# header_file_size :bigint(8) +# header_file_size :integer # header_updated_at :datetime # avatar_remote_url :string # subscription_expires_at :datetime @@ -35,7 +36,6 @@ # shared_inbox_url :string default(""), not null # followers_url :string default(""), not null # protocol :integer default(0), not null -# id :bigint(8) not null, primary key # memorial :boolean default(FALSE), not null # moved_to_account_id :bigint(8) # featured_collection_url :string @@ -43,10 +43,10 @@ # actor_type :string # discoverable :boolean # also_known_as :string is an Array -# is_pro :boolean default(FALSE), not null -# pro_expires_at :datetime # silenced_at :datetime # suspended_at :datetime +# is_pro :boolean default(FALSE), not null +# pro_expires_at :datetime # is_verified :boolean default(FALSE), not null # is_donor :boolean default(FALSE), not null # is_investor :boolean default(FALSE), not null diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 83134d41..e1e79acc 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true class ApplicationRecord < ActiveRecord::Base + connects_to database: { + writing: :master, + reading: :slave1 + } self.abstract_class = true include Remotable end diff --git a/app/models/backup.rb b/app/models/backup.rb index 82ca0340..c2651313 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -7,7 +7,7 @@ # user_id :bigint(8) # dump_file_name :string # dump_content_type :string -# dump_file_size :bigint(8) +# dump_file_size :integer # dump_updated_at :datetime # processed :boolean default(FALSE), not null # created_at :datetime not null diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 9b0ef516..9cfdc168 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -8,7 +8,7 @@ # domain :string # image_file_name :string # image_content_type :string -# image_file_size :bigint(8) +# image_file_size :integer # image_updated_at :datetime # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/group.rb b/app/models/group.rb index d241399a..a7bb71aa 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -8,7 +8,7 @@ # description :string not null # cover_image_file_name :string # cover_image_content_type :string -# cover_image_file_size :bigint(8) +# cover_image_file_size :integer # cover_image_updated_at :datetime # is_nsfw :boolean default(FALSE), not null # is_featured :boolean default(FALSE), not null @@ -18,7 +18,7 @@ # member_count :integer default(0) # slug :text # is_private :boolean default(FALSE) -# is_visible :boolean default(TRUE) +# is_visible :boolean default(FALSE) # tags :string default([]), is an Array # password :string # group_category_id :integer diff --git a/app/models/home_feed.rb b/app/models/home_feed.rb index 1a1c6ff8..cd3f4f5b 100644 --- a/app/models/home_feed.rb +++ b/app/models/home_feed.rb @@ -8,7 +8,9 @@ class HomeFeed < Feed end def get(limit = 20, max_id = nil, since_id = nil, min_id = nil) - from_database(limit, max_id, since_id, min_id) + ActiveRecord::Base.connected_to(role: :reading) do + from_database(limit, max_id, since_id, min_id) + end end private diff --git a/app/models/list_account.rb b/app/models/list_account.rb index a93d1efc..f26ba277 100644 --- a/app/models/list_account.rb +++ b/app/models/list_account.rb @@ -6,7 +6,7 @@ # id :bigint(8) not null, primary key # list_id :bigint(8) not null # account_id :bigint(8) not null -# follow_id :bigint(8) +# follow_id :bigint(8) default(1) # class ListAccount < ApplicationRecord diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 4fbe14d7..239329c4 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -3,10 +3,11 @@ # # Table name: media_attachments # +# id :bigint(8) not null, primary key # status_id :bigint(8) # file_file_name :string # file_content_type :string -# file_file_size :bigint(8) +# file_file_size :integer # file_updated_at :datetime # remote_url :string default(""), not null # created_at :datetime not null @@ -15,7 +16,6 @@ # type :integer default("image"), not null # file_meta :json # account_id :bigint(8) -# id :bigint(8) not null, primary key # description :text # scheduled_status_id :bigint(8) # blurhash :string diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index ea808578..36f9de5d 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -9,7 +9,7 @@ # description :string default(""), not null # image_file_name :string # image_content_type :string -# image_file_size :bigint(8) +# image_file_size :integer # image_updated_at :datetime # type :integer default("link"), not null # html :text default(""), not null diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb index e43d59b7..58a6495c 100644 --- a/app/models/session_activation.rb +++ b/app/models/session_activation.rb @@ -44,10 +44,13 @@ class SessionActivation < ApplicationRecord end def activate(**options) - SessionActivation.record_timestamps = true - activation = create!(options) - purge_old - SessionActivation.record_timestamps = false + activation = nil + ActiveRecord::Base.connected_to(role: :writing) do + SessionActivation.record_timestamps = true + activation = create!(options) + purge_old + SessionActivation.record_timestamps = false + end activation end @@ -72,12 +75,16 @@ class SessionActivation < ApplicationRecord end def assign_access_token - superapp = Doorkeeper::Application.find_by(superapp: true) + ActiveRecord::Base.connected_to(role: :writing) do - self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id, - resource_owner_id: user_id, - scopes: 'read write follow', - expires_in: Doorkeeper.configuration.access_token_expires_in, - use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?) + superapp = Doorkeeper::Application.find_by(superapp: true) + + self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id, + resource_owner_id: user_id, + scopes: 'read write follow', + expires_in: Doorkeeper.configuration.access_token_expires_in, + use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?) + end + self.access_token end end diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb index 108115e3..cf10b30f 100644 --- a/app/models/site_upload.rb +++ b/app/models/site_upload.rb @@ -7,7 +7,7 @@ # var :string default(""), not null # file_file_name :string # file_content_type :string -# file_file_size :bigint(8) +# file_file_size :integer # file_updated_at :datetime # meta :json # created_at :datetime not null diff --git a/app/models/user.rb b/app/models/user.rb index cf283791..f282598b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -155,26 +155,34 @@ class User < ApplicationRecord end def update_tracked_fields!(request) - super - prepare_returning_user! + ru = nil + ActiveRecord::Base.connected_to(role: :writing) do + super + ru = prepare_returning_user! + end + ru end def update_sign_in!(request, new_sign_in: false) - old_current, new_current = current_sign_in_at, Time.now.utc - self.last_sign_in_at = old_current || new_current - self.current_sign_in_at = new_current + ru = nil + ActiveRecord::Base.connected_to(role: :writing) do + old_current, new_current = current_sign_in_at, Time.now.utc + self.last_sign_in_at = old_current || new_current + self.current_sign_in_at = new_current - old_current, new_current = current_sign_in_ip, request.remote_ip - self.last_sign_in_ip = old_current || new_current - self.current_sign_in_ip = new_current + old_current, new_current = current_sign_in_ip, request.remote_ip + self.last_sign_in_ip = old_current || new_current + self.current_sign_in_ip = new_current - if new_sign_in - self.sign_in_count ||= 0 - self.sign_in_count += 1 + if new_sign_in + self.sign_in_count ||= 0 + self.sign_in_count += 1 + end + + save(validate: false) unless new_record? + ru = prepare_returning_user! end - - save(validate: false) unless new_record? - prepare_returning_user! + ru end def disable_two_factor! @@ -233,6 +241,7 @@ class User < ApplicationRecord end def web_push_subscription(session) + return nil if session.nil? session.web_push_subscription.nil? ? nil : session.web_push_subscription end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index 0f3af636..bde014c3 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -14,7 +14,6 @@ class FavouriteService < BaseService begin favourite = Favourite.find_by(account: account, status: status) rescue ActiveRecord::RecordNotFound - Favourite.connection.stick_to_master! favourite = Favourite.find_by(account: account, status: status) end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 6b057e10..c93bad58 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -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? - @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)) hasVideoOrGif = @media.find(&:video?) || @media.find(&:gifv?) diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 025d8121..13d87c21 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -14,12 +14,7 @@ class ReblogService < BaseService authorize_with account, reblogged_status, :reblog? reblog = nil - begin - 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 + reblog = account.statuses.find_by(reblog: reblogged_status) return reblog unless reblog.nil? diff --git a/config/database.yml b/config/database.yml index a66dc47c..22301538 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,21 +6,24 @@ default: &default sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %> development: - <<: *default - adapter: postgresql_makara - prepared_statements: false - database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> - username: <%= ENV['DB_USER'] %> - password: <%= ENV['DB_PASS'] %> - host: <%= ENV['DB_HOST'] %> - port: <%= ENV['DB_PORT'] %> - makara: - id: postgres - sticky: true - connections: - - role: master - blacklist_duration: 0 - - role: slave + 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 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". @@ -33,12 +36,34 @@ test: host: <%= ENV['DB_HOST'] %> port: <%= ENV['DB_PORT'] %> -production: - <<: *default - database: <%= ENV['DB_NAME'] || 'gabsocial_production' %> - username: <%= ENV['DB_USER'] || 'gabsocial' %> - password: <%= ENV['DB_PASS'] || '' %> - host: <%= ENV['DB_HOST'] || 'localhost' %> - port: <%= ENV['DB_PORT'] || 5432 %> - prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %> +#production: +# <<: *default +# database: <%= ENV['DB_NAME'] || 'gabsocial_production' %> +# username: <%= ENV['DB_USER'] || 'gabsocial' %> +# password: <%= ENV['DB_PASS'] || '' %> +# host: <%= ENV['DB_HOST'] || 'localhost' %> +# port: <%= ENV['DB_PORT'] || 5432 %> +# 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 + + diff --git a/config/environments/production.rb b/config/environments/production.rb index 071543bd..b68776d2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -131,7 +131,7 @@ Rails.application.configure do # DatabaseSelector middleware is designed as such you can define your own # strategy for connection switching and pass that into the middleware through # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session + config.active_record.database_selector = { delay: 2.seconds } + config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index bae1b731..2e18f789 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,8 +1,11 @@ Warden::Manager.after_set_user except: :fetch do |user, warden| - 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'] - else - session_id = user.activate_session(warden.request) + session_id = nil + ActiveRecord::Base.connected_to(role: :writing) do + 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'] + else + session_id = user.activate_session(warden.request) + end end warden.cookies.signed['_session_id'] = { @@ -14,17 +17,20 @@ Warden::Manager.after_set_user except: :fetch do |user, warden| end Warden::Manager.after_fetch do |user, warden| - if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id']) - warden.cookies.signed['_session_id'] = { - value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'], - expires: 1.year.from_now, - httponly: true, - secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), - } - else - warden.logout - throw :warden, message: :unauthenticated + ActiveRecord::Base.connected_to(role: :writing) do + if user.session_active?(warden.cookies.signed['_session_id'] || warden.raw_session['auth_id']) + warden.cookies.signed['_session_id'] = { + value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'], + expires: 1.year.from_now, + httponly: true, + secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), + } + else + warden.logout + throw :warden, message: :unauthenticated + end end + warden.cookies.signed['_session_id'] end Warden::Manager.before_logout do |_, warden| diff --git a/config/routes.rb b/config/routes.rb index b986899f..05c1be30 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,9 +16,6 @@ Rails.application.routes.draw do mount PgHero::Engine, at: 'pghero', as: :pghero end - Doorkeeper::AccessToken.connection.stick_to_master! - Doorkeeper::AccessGrant.connection.stick_to_master! - SessionActivation.connection.stick_to_master! SessionActivation.record_timestamps = false use_doorkeeper do diff --git a/db/master_schema.rb b/db/master_schema.rb new file mode 100644 index 00000000..8b65aaba --- /dev/null +++ b/db/master_schema.rb @@ -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 diff --git a/db/slave1_schema.rb b/db/slave1_schema.rb new file mode 100644 index 00000000..8b65aaba --- /dev/null +++ b/db/slave1_schema.rb @@ -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 diff --git a/db/slave2_schema.rb b/db/slave2_schema.rb new file mode 100644 index 00000000..8b65aaba --- /dev/null +++ b/db/slave2_schema.rb @@ -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