akkoma/priv/repo/migrations/20221216170712_create_feed_tables.exs

53 lines
1.4 KiB
Elixir

defmodule Pleroma.Repo.Migrations.CreateFeedTables do
use Ecto.Migration
def change do
create table(:feed_topics) do
add(:url, :text)
add(:expires_at, :naive_datetime)
timestamps()
end
create unique_index(:feed_topics, [:url])
create index(:feed_topics, :expires_at)
create table(:feed_subscriptions) do
add(:topic_id, references(:feed_topics, on_delete: :delete_all))
add(:api, :string)
add(:callback_url, :text)
add(:diff_domain, :boolean, null: false, default: false)
add(:secret, :string, nullable: true)
add(:lease_seconds, :float)
add(:expires_at, :naive_datetime)
timestamps()
end
create(unique_index(:feed_subscriptions, [:api, :topic_id, :callback_url]))
create(index(:feed_subscriptions, :expires_at))
create table(:feed_updates) do
add(:topic_id, references(:feed_topics, on_delete: :delete_all))
add(:headers, :binary)
add(:content_type, :text)
add(:links, {:array, :text})
add(:body, :binary)
add(:hash, :string)
timestamps()
end
create(index(:feed_updates, :inserted_at))
create table(:feed_subscription_updates) do
add(:update_id, references(:feed_updates, on_delete: :delete_all))
add(:subscription_id, references(:feed_subscriptions, on_delete: :delete_all))
add(:status_code, :integer)
add(:pushed_at, :naive_datetime)
timestamps()
end
end
end