2020-03-28 15:49:03 +00:00
|
|
|
defmodule Pleroma.Repo.Migrations.ChangeFollowingRelationshipsStateToInteger do
|
|
|
|
use Ecto.Migration
|
|
|
|
|
2020-03-31 06:21:42 +00:00
|
|
|
@alter_following_relationship_state "ALTER TABLE following_relationships ALTER COLUMN state"
|
2020-03-28 15:49:03 +00:00
|
|
|
|
|
|
|
def up do
|
|
|
|
execute("""
|
2020-03-31 06:21:42 +00:00
|
|
|
#{@alter_following_relationship_state} TYPE integer USING
|
2020-03-28 15:49:03 +00:00
|
|
|
CASE
|
|
|
|
WHEN state = 'pending' THEN 1
|
|
|
|
WHEN state = 'accept' THEN 2
|
|
|
|
WHEN state = 'reject' THEN 3
|
|
|
|
ELSE 0
|
|
|
|
END;
|
|
|
|
""")
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
|
|
|
execute("""
|
2020-03-31 06:21:42 +00:00
|
|
|
#{@alter_following_relationship_state} TYPE varchar(255) USING
|
2020-03-28 15:49:03 +00:00
|
|
|
CASE
|
|
|
|
WHEN state = 1 THEN 'pending'
|
|
|
|
WHEN state = 2 THEN 'accept'
|
|
|
|
WHEN state = 3 THEN 'reject'
|
|
|
|
ELSE ''
|
|
|
|
END;
|
|
|
|
""")
|
|
|
|
end
|
|
|
|
end
|