Fixup old migrations.
This commit is contained in:
parent
7c82b82197
commit
78485e24ac
5 changed files with 23 additions and 19 deletions
|
@ -2,7 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddIdContraintsToActivitiesAndObjects do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def change do
|
||||||
create index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index)
|
# This was wrong, make it a noop.
|
||||||
create index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index)
|
# create index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index)
|
||||||
|
# create index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddIdContraintsToActivitiesAndObjectsPartTwo d
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def change do
|
||||||
drop index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index)
|
drop_if_exists index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index)
|
||||||
drop index(:activities, ["(data->>\"id\")"], name: :activities_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(:objects, ["(data->>'id')"], name: :objects_unique_apid_index)
|
||||||
create unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index)
|
create unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddObjectActivityIndex do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddObjectActivityIndexPartTwo do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
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)
|
create index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,21 +8,23 @@ def up do
|
||||||
alter table(:users) do
|
alter table(:users) do
|
||||||
add :follower_address, :string, unique: true
|
add :follower_address, :string, unique: true
|
||||||
end
|
end
|
||||||
flush()
|
|
||||||
|
|
||||||
children = [
|
# Not needed anymore for new setups.
|
||||||
# Start the endpoint when the application starts
|
# flush()
|
||||||
supervisor(Pleroma.Web.Endpoint, [])
|
|
||||||
]
|
|
||||||
opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
|
|
||||||
Supervisor.start_link(children, opts)
|
|
||||||
|
|
||||||
Enum.each(Repo.all(User), fn (user) ->
|
# children = [
|
||||||
if !user.follower_address do
|
# # Start the endpoint when the application starts
|
||||||
cs = Ecto.Changeset.change(user, %{follower_address: User.ap_followers(user)})
|
# supervisor(Pleroma.Web.Endpoint, [])
|
||||||
Repo.update!(cs)
|
# ]
|
||||||
end
|
# opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
|
||||||
end)
|
# 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
|
end
|
||||||
|
|
||||||
def down do
|
def down do
|
||||||
|
|
Loading…
Reference in a new issue