From 78485e24acdf2f1d2f6e38c5a827bdd9c8119908 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 17 Sep 2017 00:01:49 +0200 Subject: [PATCH] Fixup old migrations. --- ...d_contraints_to_activities_and_objects.exs | 5 ++-- ...nts_to_activities_and_objects_part_two.exs | 4 +-- ...170620133028_add_object_activity_index.exs | 3 +- ...420_add_object_activity_index_part_two.exs | 2 +- ...719152213_add_follower_address_to_user.exs | 28 ++++++++++--------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/priv/repo/migrations/20170501124823_add_id_contraints_to_activities_and_objects.exs b/priv/repo/migrations/20170501124823_add_id_contraints_to_activities_and_objects.exs index 21534adc7..cebaa7c4e 100644 --- a/priv/repo/migrations/20170501124823_add_id_contraints_to_activities_and_objects.exs +++ b/priv/repo/migrations/20170501124823_add_id_contraints_to_activities_and_objects.exs @@ -2,7 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddIdContraintsToActivitiesAndObjects do use Ecto.Migration def change do - create index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index) - create index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index) + # This was wrong, make it a noop. + # create index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index) + # create index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index) end end diff --git a/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs b/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs index 12eea1369..1472b60b4 100644 --- a/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs +++ b/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs @@ -2,8 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddIdContraintsToActivitiesAndObjectsPartTwo d use Ecto.Migration def change do - drop index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index) - drop index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index) + drop_if_exists index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index) + drop_if_exists index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index) create unique_index(:objects, ["(data->>'id')"], name: :objects_unique_apid_index) create unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index) end diff --git a/priv/repo/migrations/20170620133028_add_object_activity_index.exs b/priv/repo/migrations/20170620133028_add_object_activity_index.exs index 1abbd7802..df0b8391e 100644 --- a/priv/repo/migrations/20170620133028_add_object_activity_index.exs +++ b/priv/repo/migrations/20170620133028_add_object_activity_index.exs @@ -2,6 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddObjectActivityIndex do use Ecto.Migration def change do - create index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) + # This was wrong, now a noop + # create index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) end end diff --git a/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs b/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs index 705a05f82..8d5a95c45 100644 --- a/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs +++ b/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddObjectActivityIndexPartTwo do use Ecto.Migration def change do - drop index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) + drop_if_exists index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) create index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) end end diff --git a/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs b/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs index bd3c93bd5..4d163ce0b 100644 --- a/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs +++ b/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs @@ -8,21 +8,23 @@ defmodule Pleroma.Repo.Migrations.AddFollowerAddressToUser do alter table(:users) do add :follower_address, :string, unique: true end - flush() - children = [ - # Start the endpoint when the application starts - supervisor(Pleroma.Web.Endpoint, []) - ] - opts = [strategy: :one_for_one, name: Pleroma.Supervisor] - Supervisor.start_link(children, opts) + # Not needed anymore for new setups. + # flush() - Enum.each(Repo.all(User), fn (user) -> - if !user.follower_address do - cs = Ecto.Changeset.change(user, %{follower_address: User.ap_followers(user)}) - Repo.update!(cs) - end - end) + # children = [ + # # Start the endpoint when the application starts + # supervisor(Pleroma.Web.Endpoint, []) + # ] + # opts = [strategy: :one_for_one, name: Pleroma.Supervisor] + # Supervisor.start_link(children, opts) + + # Enum.each(Repo.all(User), fn (user) -> + # if !user.follower_address do + # cs = Ecto.Changeset.change(user, %{follower_address: User.ap_followers(user)}) + # Repo.update!(cs) + # end + # end) end def down do -- 2.45.2