move to 2.5.5
[anni] / priv / repo / migrations / 20210420204354_delete_hashtags_objects_cascade.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.DeleteHashtagsObjectsCascade do
6   use Ecto.Migration
7
8   def up do
9     execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey")
10
11     alter table(:hashtags_objects) do
12       modify(:object_id, references(:objects, on_delete: :delete_all))
13     end
14   end
15
16   def down do
17     execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey")
18
19     alter table(:hashtags_objects) do
20       modify(:object_id, references(:objects, on_delete: :nothing))
21     end
22   end
23 end