20240312105620_create_severed_relationships.rb 1.4 KB

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class CreateSeveredRelationships < ActiveRecord::Migration[7.0]
  3. def change
  4. create_table :severed_relationships do |t|
  5. # No need to have an index on this foreign key as it is covered by `index_severed_relationships_on_unique_tuples`
  6. t.references :relationship_severance_event, null: false, foreign_key: { on_delete: :cascade }, index: false
  7. # No need to have an index on this foregin key as it is covered by `index_severed_relationships_on_local_account_and_event`
  8. t.references :local_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }, index: false
  9. t.references :remote_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }
  10. # Used to describe whether `local_account` is the active (follower) or passive (followed) part of the relationship
  11. t.integer :direction, null: false
  12. # Those attributes are carried over from the `follows` table
  13. t.boolean :show_reblogs
  14. t.boolean :notify
  15. t.string :languages, array: true
  16. t.timestamps
  17. t.index [:relationship_severance_event_id, :local_account_id, :direction, :remote_account_id], name: 'index_severed_relationships_on_unique_tuples', unique: true
  18. t.index [:local_account_id, :relationship_severance_event_id], name: 'index_severed_relationships_on_local_account_and_event'
  19. end
  20. end
  21. end