mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
mix format
This commit is contained in:
parent
952d7bca4f
commit
e13d3ff62e
1 changed files with 16 additions and 11 deletions
|
@ -2,20 +2,25 @@ defmodule Philomena.Repo.Migrations.AddIndexPostsOnTopicIdAndTopicPosition do
|
|||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
execute("drop index index_posts_on_topic_id_and_topic_position;");
|
||||
execute(
|
||||
"""
|
||||
execute("drop index index_posts_on_topic_id_and_topic_position;")
|
||||
|
||||
execute("""
|
||||
with mismatched_ranks as (select id,rank from (select id, topic_position, (rank() over (partition by topic_id order by created_at,id asc))-1 as rank from posts) s where s.topic_position <> s.rank)
|
||||
update posts set topic_position=mismatched_ranks.rank
|
||||
from mismatched_ranks
|
||||
where posts.id=mismatched_ranks.id;
|
||||
""");
|
||||
execute("create unique index index_posts_on_topic_id_and_topic_position on posts (topic_id, topic_position);");
|
||||
""")
|
||||
|
||||
execute(
|
||||
"create unique index index_posts_on_topic_id_and_topic_position on posts (topic_id, topic_position);"
|
||||
)
|
||||
end
|
||||
|
||||
def down do
|
||||
execute("drop index index_posts_on_topic_id_and_topic_position;");
|
||||
execute("create index index_posts_on_topic_id_and_topic_position on public.posts (topic_id, topic_position);");
|
||||
end
|
||||
execute("drop index index_posts_on_topic_id_and_topic_position;")
|
||||
|
||||
execute(
|
||||
"create index index_posts_on_topic_id_and_topic_position on public.posts (topic_id, topic_position);"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue