summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20190912065617_create_deliveries.exs
blob: 5a43c3716efe1e85b1d173e9ae64bb686d035e35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Repo.Migrations.CreateDeliveries do
  use Ecto.Migration

  def change do
    create_if_not_exists table(:deliveries) do
      add(:object_id, references(:objects, type: :id), null: false)
      add(:user_id, references(:users, type: :uuid, on_delete: :delete_all), null: false)
    end

    create_if_not_exists(index(:deliveries, :object_id, name: :deliveries_object_id))
    create_if_not_exists(unique_index(:deliveries, [:user_id, :object_id]))
  end
end