2022-03-08 05:06:07 +00:00
|
|
|
defmodule Pleroma.Repo.Migrations.CreateAnnouncements do
|
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def change do
|
|
|
|
create_if_not_exists table(:announcements, primary_key: false) do
|
|
|
|
add(:id, :uuid, primary_key: true)
|
|
|
|
add(:data, :map)
|
2022-03-08 23:21:20 +00:00
|
|
|
add(:starts_at, :naive_datetime)
|
|
|
|
add(:ends_at, :naive_datetime)
|
2022-03-09 04:00:51 +00:00
|
|
|
add(:rendered, :map)
|
2022-03-08 05:06:07 +00:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
create_if_not_exists table(:announcement_read_relationships) do
|
|
|
|
add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
|
|
|
|
add(:announcement_id, references(:announcements, type: :uuid, on_delete: :delete_all))
|
|
|
|
|
|
|
|
timestamps(updated_at: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
create_if_not_exists(
|
|
|
|
unique_index(:announcement_read_relationships, [:user_id, :announcement_id])
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|