863 B · text History 3a1226c
defmodule OhMyExOhIrcd.Repo.Migrations.CreateChannelTopics do
  use Ecto.Migration

  # Topic persistence, decoupled from channel *registration*. Every channel
  # — registered or not — that has a topic set gets a row here, so topics
  # survive pod restarts / deploys (when the in-memory Channel singletons
  # are torn down and rebuilt). The `channels` table stays reserved for
  # ChanServ registrations (founder/modes/feature configs key off it).
  def change do
    create table(:channel_topics) do
      add :name, :string, null: false
      add :topic, :text, null: false, default: ""
      add :set_by, :string, default: ""
      # Unix seconds — mirrors the in-memory `topic_set_at` used for RPL 333.
      add :set_at, :bigint, default: 0

      timestamps(type: :utc_datetime)
    end

    create unique_index(:channel_topics, [:name])
  end
end