class CreateTheatreWatchingUsers < ActiveRecord::Migration[8.0]
  def change
    create_table :theatre_watching_users, primary_key: [:theatre_id, :user_id] do |t|
      t.references :theatre, null: false, foreign_key: { to_table: :theatres }
      t.references :user, null: false, foreign_key: { to_table: :users }, index: true
      t.datetime :expires_at, null: false, index: true
      t.timestamps

      t.index [:theatre_id, :expires_at]
    end
  end
end
