930 B · text History 4b6fe3b
defmodule OhMyExOhIrcd.Repo.Migrations.CreateImageChannelConfigs do
  use Ecto.Migration

  def change do
    create table(:image_channel_configs) do
      add :channel_id, references(:channels, on_delete: :delete_all), null: false
      add :enabled, :boolean, null: false, default: true
      add :joined, :boolean, null: false, default: false

      add :format, :string,
        null: false,
        default: "%who% posted an image: %url% %title%"

      add :rate_limit_seconds, :integer, null: false, default: 30
      add :restrict_to_allowlist, :boolean, null: false, default: false
      add :allowlist, {:array, :string}, null: false, default: []
      # Per-channel override of the server's default retention window.
      # NULL means "use the server default".
      add :retention_days, :integer

      timestamps(type: :utc_datetime)
    end

    create unique_index(:image_channel_configs, [:channel_id])
  end
end