2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Repo.Migrations.AddPrimaryKeyToMember do
|
2018-08-24 11:34:00 +02:00
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def up do
|
|
|
|
execute("ALTER TABLE members DROP CONSTRAINT IF EXISTS members_pkey")
|
2019-02-22 14:18:52 +01:00
|
|
|
drop_if_exists(index(:members, ["members_account_id_index"]))
|
|
|
|
|
|
|
|
create(
|
|
|
|
unique_index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index)
|
|
|
|
)
|
|
|
|
|
2018-08-24 11:34:00 +02:00
|
|
|
alter table(:members) do
|
2019-02-22 14:18:52 +01:00
|
|
|
add(:id, :serial, primary_key: true)
|
2018-08-24 11:34:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
2019-02-22 14:18:52 +01:00
|
|
|
drop(index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index))
|
|
|
|
|
2018-08-24 11:34:00 +02:00
|
|
|
alter table(:members) do
|
2019-02-22 14:18:52 +01:00
|
|
|
remove(:id)
|
2018-08-24 11:34:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|