summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-04-13 09:23:50 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-04-13 09:23:50 +0300
commitf00ff20768cbbb6eb5a6442772335dbe60fde6d4 (patch)
tree934dba7fb5aa850a3a35b229bd7c6020ca3b2816 /priv
parentc556efb761a3e7fc2beb4540d6f58dbfe8e4abfe (diff)
parent7ee35eb9a6a55ef610eb02a04a33f67e5921cff3 (diff)
downloadpleroma-f00ff20768cbbb6eb5a6442772335dbe60fde6d4.tar.gz
pleroma-f00ff20768cbbb6eb5a6442772335dbe60fde6d4.zip
Merge remote-tracking branch 'remotes/origin/develop' into 1364-no-pushes-from-blocked-domains-users
# Conflicts: # lib/pleroma/following_relationship.ex
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20200328124805_change_following_relationships_state_to_integer.exs29
-rw-r--r--priv/repo/migrations/20200328130139_add_following_relationships_following_id_index.exs11
2 files changed, 40 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200328124805_change_following_relationships_state_to_integer.exs b/priv/repo/migrations/20200328124805_change_following_relationships_state_to_integer.exs
new file mode 100644
index 000000000..2b0820f3f
--- /dev/null
+++ b/priv/repo/migrations/20200328124805_change_following_relationships_state_to_integer.exs
@@ -0,0 +1,29 @@
+defmodule Pleroma.Repo.Migrations.ChangeFollowingRelationshipsStateToInteger do
+ use Ecto.Migration
+
+ @alter_following_relationship_state "ALTER TABLE following_relationships ALTER COLUMN state"
+
+ def up do
+ execute("""
+ #{@alter_following_relationship_state} TYPE integer USING
+ CASE
+ WHEN state = 'pending' THEN 1
+ WHEN state = 'accept' THEN 2
+ WHEN state = 'reject' THEN 3
+ ELSE 0
+ END;
+ """)
+ end
+
+ def down do
+ execute("""
+ #{@alter_following_relationship_state} TYPE varchar(255) USING
+ CASE
+ WHEN state = 1 THEN 'pending'
+ WHEN state = 2 THEN 'accept'
+ WHEN state = 3 THEN 'reject'
+ ELSE ''
+ END;
+ """)
+ end
+end
diff --git a/priv/repo/migrations/20200328130139_add_following_relationships_following_id_index.exs b/priv/repo/migrations/20200328130139_add_following_relationships_following_id_index.exs
new file mode 100644
index 000000000..884832f84
--- /dev/null
+++ b/priv/repo/migrations/20200328130139_add_following_relationships_following_id_index.exs
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.AddFollowingRelationshipsFollowingIdIndex do
+ use Ecto.Migration
+
+ # [:follower_index] index is useless because of [:follower_id, :following_id] index
+ # [:following_id] index makes sense because of user's followers-targeted queries
+ def change do
+ drop_if_exists(index(:following_relationships, [:follower_id]))
+
+ create_if_not_exists(index(:following_relationships, [:following_id]))
+ end
+end