From 32808208bef12996f819d21ca2635837aff98cbf Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 8 Oct 2019 15:16:39 +0300 Subject: [PATCH] Enable `mix format` for migrations --- .formatter.exs | 2 +- .../migrations/20170320193800_create_user.exs | 11 ++- .../20170321074828_create_activity.exs | 5 +- .../20170321074832_create_object.exs | 3 +- ...0321133335_add_following_list_to_users.exs | 2 +- .../20170321143152_add_ap_id_to_users.exs | 2 +- .../20170330153447_add_index_to_objects.exs | 2 +- ...add_unique_index_to_email_and_nickname.exs | 4 +- ...70416122418_add_avatar_object_to_users.exs | 2 +- ...143_create_webssub_server_subscription.exs | 10 +-- .../20170423154511_add_fields_to_users.exs | 4 +- ...4155_create_websub_client_subscription.exs | 10 +-- .../20170427054757_add_user_and_hub.exs | 4 +- ...nts_to_activities_and_objects_part_two.exs | 14 ++- ...02083023_add_local_field_to_activities.exs | 4 +- ...0170506222027_add_unique_index_to_apid.exs | 2 +- .../migrations/20170529093232_longer_bios.exs | 5 +- ...20170620095947_remove_activities_index.exs | 2 +- ...420_add_object_activity_index_part_two.exs | 13 ++- ...0701142005_add_actor_index_to_activity.exs | 4 +- ...719152213_add_follower_address_to_user.exs | 4 +- .../20170906120646_add_mastodon_apps.exs | 12 +-- ...906143140_create_o_auth_authorizations.exs | 10 +-- .../20170906152508_create_o_auth_token.exs | 10 +-- .../20170911123607_create_notifications.exs | 8 +- .../20170912114248_add_context_index.exs | 7 +- ...0916090107_add_fts_index_to_activities.exs | 8 +- .../20170917120416_add_tag_index.exs | 8 +- ...019141706_create_password_reset_tokens.exs | 6 +- ...035_add_second_object_index_to_activty.exs | 14 ++- .../20171024090137_drop_object_index.exs | 2 +- .../20171024121413_add_object_actor_index.exs | 7 +- .../20171109091239_add_actor_to_activity.exs | 9 +- .../20171109114020_fill_actor_field.exs | 9 +- ...109141309_add_sort_index_to_activities.exs | 2 +- ...20171130135819_add_local_index_to_user.exs | 2 +- ...212163643_add_recipients_to_activities.exs | 4 +- ...12164525_fill_recipients_in_activities.exs | 12 ++- ...21210540_make_following_postgres_array.exs | 11 +-- ...51_add_follower_address_index_to_users.exs | 4 +- ...7174350_drop_local_index_on_activities.exs | 2 +- ...180327175831_actually_drop_local_index.exs | 4 +- .../20180429094642_create_lists.exs | 8 +- .../20180513104714_modify_activity_index.exs | 4 +- .../20180516144508_add_trigram_extension.exs | 11 ++- ...180516154905_create_user_trigram_index.exs | 4 +- .../20180530123448_add_list_follow_index.exs | 2 +- ...3637_create_apid_host_extraction_index.exs | 7 +- ...180612110515_create_user_invite_tokens.exs | 4 +- ...40_create_activities_in_reply_to_index.exs | 7 +- .../20180813003722_create_filters.exs | 21 +++-- ...ipients_to_and_cc_fields_to_activities.exs | 8 +- ...829182612_activities_add_to_cc_indices.exs | 9 +- ...ients_to_and_cc_fields_from_activities.exs | 8 +- ...903114437_users_add_is_moderator_index.exs | 4 +- ...180918182427_create_push_subscriptions.exs | 14 +-- ...0919060348_users_add_last_refreshed_at.exs | 2 +- .../20181206125616_add_tags_to_users.exs | 4 +- .../20181214121049_add_bookmarks_to_users.exs | 2 +- ...18172826_users_and_activities_flake_id.exs | 87 +++++++++++-------- ...20190109152453_add_visibility_function.exs | 4 +- .../20190115085500_create_user_fts_index.exs | 24 ++--- ...90122153157_update_activity_visibility.exs | 2 - ...0190123092341_users_add_is_admin_index.exs | 4 +- .../20190123125546_create_instances.exs | 8 +- ...31141_update_activity_visibility_again.exs | 3 - ...90127151220_add_activities_likes_index.exs | 8 +- .../20190203185340_split_hide_network.exs | 14 ++- .../20190205114625_create_thread_mutes.exs | 6 +- ...08131753_add_scopes_to_o_auth_entities.exs | 2 +- ...03_change_apps_scopes_to_varchar_array.exs | 18 ++-- ..._data_migration_populate_o_auth_scopes.exs | 2 +- ...104808_data_migration_normalize_scopes.exs | 2 +- ...0190301101154_add_default_tags_to_user.exs | 2 +- ...190303120636_update_user_note_counters.exs | 8 +- .../20190315101315_create_registrations.exs | 14 +-- ...325185009_create_notification_id_index.exs | 2 +- ...0190405160700_add_index_on_subscribers.exs | 8 +- .../20190408123347_create_conversations.exs | 6 +- ...859_add_participation_updated_at_index.exs | 2 +- ...120_add_index_on_user_info_deactivated.exs | 4 +- .../20190414125034_migrate_old_bookmarks.exs | 4 +- ...0190501125843_add_fts_index_to_objects.exs | 15 +++- ...511191044_set_default_state_to_reports.exs | 8 +- ...809_change_hide_column_in_filter_table.exs | 4 +- ...603162018_add_object_in_reply_to_index.exs | 2 +- ...0190603173419_add_tag_index_to_objects.exs | 7 +- ...2024_copy_muted_to_muted_notifications.exs | 4 +- ...ersation_participation_recipient_ships.exs | 4 +- ...90823000549_add_likes_index_to_objects.exs | 2 +- .../20190912065617_create_deliveries.exs | 3 +- ...0929201536_drop_subscription_if_exists.exs | 2 +- .../20191006123824_add_keys_column.exs | 2 +- ...006135457_move_keys_to_separate_column.exs | 5 +- 94 files changed, 406 insertions(+), 265 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 2bed17cc0..7fa95a619 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,3 +1,3 @@ [ - inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}", "priv/repo/migrations/*.exs"] ] diff --git a/priv/repo/migrations/20170320193800_create_user.exs b/priv/repo/migrations/20170320193800_create_user.exs index 089964a26..e5f6ac52e 100644 --- a/priv/repo/migrations/20170320193800_create_user.exs +++ b/priv/repo/migrations/20170320193800_create_user.exs @@ -3,14 +3,13 @@ defmodule Pleroma.Repo.Migrations.CreatePleroma.User do def change do create_if_not_exists table(:users) do - add :email, :string - add :password_hash, :string - add :name, :string - add :nickname, :string - add :bio, :string + add(:email, :string) + add(:password_hash, :string) + add(:name, :string) + add(:nickname, :string) + add(:bio, :string) timestamps() end - end end diff --git a/priv/repo/migrations/20170321074828_create_activity.exs b/priv/repo/migrations/20170321074828_create_activity.exs index f5c872721..ab00a47c3 100644 --- a/priv/repo/migrations/20170321074828_create_activity.exs +++ b/priv/repo/migrations/20170321074828_create_activity.exs @@ -3,12 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreatePleroma.Activity do def change do create_if_not_exists table(:activities) do - add :data, :map + add(:data, :map) timestamps() end - create_if_not_exists index(:activities, [:data], using: :gin) - + create_if_not_exists(index(:activities, [:data], using: :gin)) end end diff --git a/priv/repo/migrations/20170321074832_create_object.exs b/priv/repo/migrations/20170321074832_create_object.exs index b184672ad..c5a59ecba 100644 --- a/priv/repo/migrations/20170321074832_create_object.exs +++ b/priv/repo/migrations/20170321074832_create_object.exs @@ -3,10 +3,9 @@ defmodule Pleroma.Repo.Migrations.CreatePleroma.Object do def change do create_if_not_exists table(:objects) do - add :data, :map + add(:data, :map) timestamps() end - end end diff --git a/priv/repo/migrations/20170321133335_add_following_list_to_users.exs b/priv/repo/migrations/20170321133335_add_following_list_to_users.exs index b02c1272c..8dd83c3f8 100644 --- a/priv/repo/migrations/20170321133335_add_following_list_to_users.exs +++ b/priv/repo/migrations/20170321133335_add_following_list_to_users.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddFollowingListToUsers do def change do alter table(:users) do - add :following, :map + add(:following, :map) end end end diff --git a/priv/repo/migrations/20170321143152_add_ap_id_to_users.exs b/priv/repo/migrations/20170321143152_add_ap_id_to_users.exs index e6f0366b5..38ceb87fd 100644 --- a/priv/repo/migrations/20170321143152_add_ap_id_to_users.exs +++ b/priv/repo/migrations/20170321143152_add_ap_id_to_users.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddApIdToUsers do def change do alter table(:users) do - add :ap_id, :string + add(:ap_id, :string) end end end diff --git a/priv/repo/migrations/20170330153447_add_index_to_objects.exs b/priv/repo/migrations/20170330153447_add_index_to_objects.exs index 25e308533..93198b462 100644 --- a/priv/repo/migrations/20170330153447_add_index_to_objects.exs +++ b/priv/repo/migrations/20170330153447_add_index_to_objects.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddIndexToObjects do use Ecto.Migration def change do - create_if_not_exists index(:objects, [:data], using: :gin) + create_if_not_exists(index(:objects, [:data], using: :gin)) end end diff --git a/priv/repo/migrations/20170415141210_add_unique_index_to_email_and_nickname.exs b/priv/repo/migrations/20170415141210_add_unique_index_to_email_and_nickname.exs index 42da88954..b18c67dcb 100644 --- a/priv/repo/migrations/20170415141210_add_unique_index_to_email_and_nickname.exs +++ b/priv/repo/migrations/20170415141210_add_unique_index_to_email_and_nickname.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddUniqueIndexToEmailAndNickname do use Ecto.Migration def change do - create_if_not_exists unique_index(:users, [:email]) - create_if_not_exists unique_index(:users, [:nickname]) + create_if_not_exists(unique_index(:users, [:email])) + create_if_not_exists(unique_index(:users, [:nickname])) end end diff --git a/priv/repo/migrations/20170416122418_add_avatar_object_to_users.exs b/priv/repo/migrations/20170416122418_add_avatar_object_to_users.exs index b6d8742dc..e88752c30 100644 --- a/priv/repo/migrations/20170416122418_add_avatar_object_to_users.exs +++ b/priv/repo/migrations/20170416122418_add_avatar_object_to_users.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddAvatarObjectToUsers do def change do alter table(:users) do - add :avatar, :map + add(:avatar, :map) end end end diff --git a/priv/repo/migrations/20170418200143_create_webssub_server_subscription.exs b/priv/repo/migrations/20170418200143_create_webssub_server_subscription.exs index 243280378..3d94e4ee7 100644 --- a/priv/repo/migrations/20170418200143_create_webssub_server_subscription.exs +++ b/priv/repo/migrations/20170418200143_create_webssub_server_subscription.exs @@ -3,11 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateWebsubServerSubscription do def change do create_if_not_exists table(:websub_server_subscriptions) do - add :topic, :string - add :callback, :string - add :secret, :string - add :valid_until, :naive_datetime - add :state, :string + add(:topic, :string) + add(:callback, :string) + add(:secret, :string) + add(:valid_until, :naive_datetime) + add(:state, :string) timestamps() end diff --git a/priv/repo/migrations/20170423154511_add_fields_to_users.exs b/priv/repo/migrations/20170423154511_add_fields_to_users.exs index 84de74bc4..a079c73bd 100644 --- a/priv/repo/migrations/20170423154511_add_fields_to_users.exs +++ b/priv/repo/migrations/20170423154511_add_fields_to_users.exs @@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.AddFieldsToUsers do def change do alter table(:users) do - add :local, :boolean, default: true - add :info, :map + add(:local, :boolean, default: true) + add(:info, :map) end end end diff --git a/priv/repo/migrations/20170426154155_create_websub_client_subscription.exs b/priv/repo/migrations/20170426154155_create_websub_client_subscription.exs index 4b79d7506..d020614e1 100644 --- a/priv/repo/migrations/20170426154155_create_websub_client_subscription.exs +++ b/priv/repo/migrations/20170426154155_create_websub_client_subscription.exs @@ -3,11 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateWebsubClientSubscription do def change do create_if_not_exists table(:websub_client_subscriptions) do - add :topic, :string - add :secret, :string - add :valid_until, :naive_datetime_usec - add :state, :string - add :subscribers, :map + add(:topic, :string) + add(:secret, :string) + add(:valid_until, :naive_datetime_usec) + add(:state, :string) + add(:subscribers, :map) timestamps() end diff --git a/priv/repo/migrations/20170427054757_add_user_and_hub.exs b/priv/repo/migrations/20170427054757_add_user_and_hub.exs index 4f9a520bd..f33a8572f 100644 --- a/priv/repo/migrations/20170427054757_add_user_and_hub.exs +++ b/priv/repo/migrations/20170427054757_add_user_and_hub.exs @@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.AddUserAndHub do def change do alter table(:websub_client_subscriptions) do - add :hub, :string - add :user_id, references(:users) + add(:hub, :string) + add(:user_id, references(:users)) end end end diff --git a/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs b/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs index f5e5cd269..ecc7c23cc 100644 --- a/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs +++ b/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs @@ -2,10 +2,16 @@ defmodule Pleroma.Repo.Migrations.AddIdContraintsToActivitiesAndObjectsPartTwo d use Ecto.Migration def up do - drop_if_exists index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index) - drop_if_exists index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index) - create_if_not_exists unique_index(:objects, ["(data->>'id')"], name: :objects_unique_apid_index) - create_if_not_exists unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index) + drop_if_exists(index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index)) + drop_if_exists(index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index)) + + create_if_not_exists( + unique_index(:objects, ["(data->>'id')"], name: :objects_unique_apid_index) + ) + + create_if_not_exists( + unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index) + ) end def down, do: :ok diff --git a/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs b/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs index cebc11d21..6b61bd464 100644 --- a/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs +++ b/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs @@ -3,9 +3,9 @@ defmodule Pleroma.Repo.Migrations.AddLocalFieldToActivities do def change do alter table(:activities) do - add :local, :boolean, default: true + add(:local, :boolean, default: true) end - create_if_not_exists index(:activities, [:local]) + create_if_not_exists(index(:activities, [:local])) end end diff --git a/priv/repo/migrations/20170506222027_add_unique_index_to_apid.exs b/priv/repo/migrations/20170506222027_add_unique_index_to_apid.exs index 1b7e33b70..80f50029a 100644 --- a/priv/repo/migrations/20170506222027_add_unique_index_to_apid.exs +++ b/priv/repo/migrations/20170506222027_add_unique_index_to_apid.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddUniqueIndexToAPID do use Ecto.Migration def change do - create_if_not_exists unique_index(:users, [:ap_id]) + create_if_not_exists(unique_index(:users, [:ap_id])) end end diff --git a/priv/repo/migrations/20170529093232_longer_bios.exs b/priv/repo/migrations/20170529093232_longer_bios.exs index 9188f4bee..e25e5e144 100644 --- a/priv/repo/migrations/20170529093232_longer_bios.exs +++ b/priv/repo/migrations/20170529093232_longer_bios.exs @@ -3,14 +3,13 @@ defmodule Pleroma.Repo.Migrations.LongerBios do def up do alter table(:users) do - modify :bio, :text + modify(:bio, :text) end end def down do alter table(:users) do - modify :bio, :string + modify(:bio, :string) end end - end diff --git a/priv/repo/migrations/20170620095947_remove_activities_index.exs b/priv/repo/migrations/20170620095947_remove_activities_index.exs index e7d41eac4..ea3d4a509 100644 --- a/priv/repo/migrations/20170620095947_remove_activities_index.exs +++ b/priv/repo/migrations/20170620095947_remove_activities_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.RemoveActivitiesIndex do use Ecto.Migration def change do - drop_if_exists index(:activities, [:data]) + drop_if_exists(index(:activities, [:data])) end end diff --git a/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs b/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs index c95218fad..c015afbe1 100644 --- a/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs +++ b/priv/repo/migrations/20170620142420_add_object_activity_index_part_two.exs @@ -2,7 +2,16 @@ defmodule Pleroma.Repo.Migrations.AddObjectActivityIndexPartTwo do use Ecto.Migration def change do - drop_if_exists index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) - create_if_not_exists index(:activities, ["(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_if_not_exists( + index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], + name: :activities_create_objects_index + ) + ) end end diff --git a/priv/repo/migrations/20170701142005_add_actor_index_to_activity.exs b/priv/repo/migrations/20170701142005_add_actor_index_to_activity.exs index 807fe3728..220c48abd 100644 --- a/priv/repo/migrations/20170701142005_add_actor_index_to_activity.exs +++ b/priv/repo/migrations/20170701142005_add_actor_index_to_activity.exs @@ -2,6 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddActorIndexToActivity do use Ecto.Migration def change do - create_if_not_exists index(:activities, ["(data->>'actor')", "inserted_at desc"], name: :activities_actor_index) + create_if_not_exists( + index(:activities, ["(data->>'actor')", "inserted_at desc"], name: :activities_actor_index) + ) end end diff --git a/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs b/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs index 591164be5..be5eca36c 100644 --- a/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs +++ b/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs @@ -3,13 +3,13 @@ defmodule Pleroma.Repo.Migrations.AddFollowerAddressToUser do def up do alter table(:users) do - add :follower_address, :string, unique: true + add(:follower_address, :string, unique: true) end end def down do alter table(:users) do - remove :follower_address + remove(:follower_address) end end end diff --git a/priv/repo/migrations/20170906120646_add_mastodon_apps.exs b/priv/repo/migrations/20170906120646_add_mastodon_apps.exs index ccd5e3fe2..0e01625ff 100644 --- a/priv/repo/migrations/20170906120646_add_mastodon_apps.exs +++ b/priv/repo/migrations/20170906120646_add_mastodon_apps.exs @@ -3,12 +3,12 @@ defmodule Pleroma.Repo.Migrations.AddMastodonApps do def change do create_if_not_exists table(:apps) do - add :client_name, :string - add :redirect_uris, :string - add :scopes, :string - add :website, :string - add :client_id, :string - add :client_secret, :string + add(:client_name, :string) + add(:redirect_uris, :string) + add(:scopes, :string) + add(:website, :string) + add(:client_id, :string) + add(:client_secret, :string) timestamps() end diff --git a/priv/repo/migrations/20170906143140_create_o_auth_authorizations.exs b/priv/repo/migrations/20170906143140_create_o_auth_authorizations.exs index 63b25c537..9af8315a8 100644 --- a/priv/repo/migrations/20170906143140_create_o_auth_authorizations.exs +++ b/priv/repo/migrations/20170906143140_create_o_auth_authorizations.exs @@ -3,11 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateOAuthAuthorizations do def change do create_if_not_exists table(:oauth_authorizations) do - add :app_id, references(:apps) - add :user_id, references(:users) - add :token, :string - add :valid_until, :naive_datetime_usec - add :used, :boolean, default: false + add(:app_id, references(:apps)) + add(:user_id, references(:users)) + add(:token, :string) + add(:valid_until, :naive_datetime_usec) + add(:used, :boolean, default: false) timestamps() end diff --git a/priv/repo/migrations/20170906152508_create_o_auth_token.exs b/priv/repo/migrations/20170906152508_create_o_auth_token.exs index 08471bbf8..bfad98b76 100644 --- a/priv/repo/migrations/20170906152508_create_o_auth_token.exs +++ b/priv/repo/migrations/20170906152508_create_o_auth_token.exs @@ -3,11 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateOAuthToken do def change do create_if_not_exists table(:oauth_tokens) do - add :app_id, references(:apps) - add :user_id, references(:users) - add :token, :string - add :refresh_token, :string - add :valid_until, :naive_datetime_usec + add(:app_id, references(:apps)) + add(:user_id, references(:users)) + add(:token, :string) + add(:refresh_token, :string) + add(:valid_until, :naive_datetime_usec) timestamps() end diff --git a/priv/repo/migrations/20170911123607_create_notifications.exs b/priv/repo/migrations/20170911123607_create_notifications.exs index 50de9c5f1..36facc5a0 100644 --- a/priv/repo/migrations/20170911123607_create_notifications.exs +++ b/priv/repo/migrations/20170911123607_create_notifications.exs @@ -3,13 +3,13 @@ defmodule Pleroma.Repo.Migrations.CreateNotifications do def change do create_if_not_exists table(:notifications) do - add :user_id, references(:users, on_delete: :delete_all) - add :activity_id, references(:activities, on_delete: :delete_all) - add :seen, :boolean, default: false + add(:user_id, references(:users, on_delete: :delete_all)) + add(:activity_id, references(:activities, on_delete: :delete_all)) + add(:seen, :boolean, default: false) timestamps() end - create_if_not_exists index(:notifications, [:user_id]) + create_if_not_exists(index(:notifications, [:user_id])) end end diff --git a/priv/repo/migrations/20170912114248_add_context_index.exs b/priv/repo/migrations/20170912114248_add_context_index.exs index 83c585136..400a432ff 100644 --- a/priv/repo/migrations/20170912114248_add_context_index.exs +++ b/priv/repo/migrations/20170912114248_add_context_index.exs @@ -3,6 +3,11 @@ defmodule Pleroma.Repo.Migrations.AddContextIndex do @disable_ddl_transaction true def change do - create index(:activities, ["(data->>'type')", "(data->>'context')"], name: :activities_context_index, concurrently: true) + create( + index(:activities, ["(data->>'type')", "(data->>'context')"], + name: :activities_context_index, + concurrently: true + ) + ) end end diff --git a/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs b/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs index c17da8309..717e25412 100644 --- a/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs +++ b/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs @@ -3,6 +3,12 @@ defmodule Pleroma.Repo.Migrations.AddFTSIndexToActivities do @disable_ddl_transaction true def change do - create index(:activities, ["(to_tsvector('english', data->'object'->>'content'))"], concurrently: true, using: :gin, name: :activities_fts) + create( + index(:activities, ["(to_tsvector('english', data->'object'->>'content'))"], + concurrently: true, + using: :gin, + name: :activities_fts + ) + ) end end diff --git a/priv/repo/migrations/20170917120416_add_tag_index.exs b/priv/repo/migrations/20170917120416_add_tag_index.exs index d9391dda9..c69e0ef8f 100644 --- a/priv/repo/migrations/20170917120416_add_tag_index.exs +++ b/priv/repo/migrations/20170917120416_add_tag_index.exs @@ -4,6 +4,12 @@ defmodule Pleroma.Repo.Migrations.AddTagIndex do @disable_ddl_transaction true def change do - create index(:activities, ["(data #> '{\"object\",\"tag\"}')"], concurrently: true, using: :gin, name: :activities_tags) + create( + index(:activities, ["(data #> '{\"object\",\"tag\"}')"], + concurrently: true, + using: :gin, + name: :activities_tags + ) + ) end end diff --git a/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs b/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs index dde0f945f..2be50d15e 100644 --- a/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs +++ b/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs @@ -3,9 +3,9 @@ defmodule Pleroma.Repo.Migrations.CreatePasswordResetTokens do def change do create_if_not_exists table(:password_reset_tokens) do - add :token, :string - add :user_id, references(:users) - add :used, :boolean, default: false + add(:token, :string) + add(:user_id, references(:users)) + add(:used, :boolean, default: false) timestamps() end diff --git a/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs b/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs index c6df53ec9..261940a96 100644 --- a/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs +++ b/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs @@ -4,7 +4,17 @@ defmodule Pleroma.Repo.Migrations.AddSecondObjectIndexToActivty do @disable_ddl_transaction true def change do - drop_if_exists index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index) - create index(:activities, ["(coalesce(data->'object'->>'id', data->>'object'))"], name: :activities_create_objects_index, concurrently: true) + drop_if_exists( + index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], + name: :activities_create_objects_index + ) + ) + + create( + index(:activities, ["(coalesce(data->'object'->>'id', data->>'object'))"], + name: :activities_create_objects_index, + concurrently: true + ) + ) end end diff --git a/priv/repo/migrations/20171024090137_drop_object_index.exs b/priv/repo/migrations/20171024090137_drop_object_index.exs index 29b4c9333..d417577ae 100644 --- a/priv/repo/migrations/20171024090137_drop_object_index.exs +++ b/priv/repo/migrations/20171024090137_drop_object_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.DropObjectIndex do use Ecto.Migration def change do - drop_if_exists index(:objects, [:data], using: :gin) + drop_if_exists(index(:objects, [:data], using: :gin)) end end diff --git a/priv/repo/migrations/20171024121413_add_object_actor_index.exs b/priv/repo/migrations/20171024121413_add_object_actor_index.exs index 344c9c825..78084536c 100644 --- a/priv/repo/migrations/20171024121413_add_object_actor_index.exs +++ b/priv/repo/migrations/20171024121413_add_object_actor_index.exs @@ -4,6 +4,11 @@ defmodule Pleroma.Repo.Migrations.AddObjectActorIndex do @disable_ddl_transaction true def change do - create index(:objects, ["(data->>'actor')", "(data->>'type')"], concurrently: true, name: :objects_actor_type) + create( + index(:objects, ["(data->>'actor')", "(data->>'type')"], + concurrently: true, + name: :objects_actor_type + ) + ) end end diff --git a/priv/repo/migrations/20171109091239_add_actor_to_activity.exs b/priv/repo/migrations/20171109091239_add_actor_to_activity.exs index fb5f80c98..91348f5c3 100644 --- a/priv/repo/migrations/20171109091239_add_actor_to_activity.exs +++ b/priv/repo/migrations/20171109091239_add_actor_to_activity.exs @@ -5,16 +5,17 @@ defmodule Pleroma.Repo.Migrations.AddActorToActivity do def up do alter table(:activities) do - add :actor, :string + add(:actor, :string) end - create index(:activities, [:actor, "id DESC NULLS LAST"], concurrently: true) + create(index(:activities, [:actor, "id DESC NULLS LAST"], concurrently: true)) end def down do - drop_if_exists index(:activities, [:actor, "id DESC NULLS LAST"]) + drop_if_exists(index(:activities, [:actor, "id DESC NULLS LAST"])) + alter table(:activities) do - remove :actor + remove(:actor) end end end diff --git a/priv/repo/migrations/20171109114020_fill_actor_field.exs b/priv/repo/migrations/20171109114020_fill_actor_field.exs index 255ca46d5..fb7eca692 100644 --- a/priv/repo/migrations/20171109114020_fill_actor_field.exs +++ b/priv/repo/migrations/20171109114020_fill_actor_field.exs @@ -5,17 +5,19 @@ defmodule Pleroma.Repo.Migrations.FillActorField do def up do max = Repo.aggregate(Activity, :max, :id) + if max do IO.puts("#{max} activities") - chunks = 0..(round(max / 10_000)) + chunks = 0..round(max / 10_000) - Enum.each(chunks, fn (i) -> + Enum.each(chunks, fn i -> min = i * 10_000 max = min + 10_000 + execute(""" update activities set actor = data->>'actor' where id > #{min} and id <= #{max}; """) - |> IO.inspect + |> IO.inspect() end) end end @@ -23,4 +25,3 @@ defmodule Pleroma.Repo.Migrations.FillActorField do def down do end end - diff --git a/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs b/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs index 2d21c56ca..37fb2ce32 100644 --- a/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs +++ b/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs @@ -3,6 +3,6 @@ defmodule Pleroma.Repo.Migrations.AddSortIndexToActivities do @disable_ddl_transaction true def change do - create index(:activities, ["id desc nulls last"], concurrently: true) + create(index(:activities, ["id desc nulls last"], concurrently: true)) end end diff --git a/priv/repo/migrations/20171130135819_add_local_index_to_user.exs b/priv/repo/migrations/20171130135819_add_local_index_to_user.exs index 3438bbbc4..76bf9584e 100644 --- a/priv/repo/migrations/20171130135819_add_local_index_to_user.exs +++ b/priv/repo/migrations/20171130135819_add_local_index_to_user.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddLocalIndexToUser do use Ecto.Migration def change do - create_if_not_exists index(:users, [:local]) + create_if_not_exists(index(:users, [:local])) end end diff --git a/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs b/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs index 4520b398e..6344fbeee 100644 --- a/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs +++ b/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs @@ -3,9 +3,9 @@ defmodule Pleroma.Repo.Migrations.AddRecipientsToActivities do def change do alter table(:activities) do - add :recipients, {:array, :string} + add(:recipients, {:array, :string}) end - create_if_not_exists index(:activities, [:recipients], using: :gin) + create_if_not_exists(index(:activities, [:recipients], using: :gin)) end end diff --git a/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs b/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs index 87de64ca5..6dfa93716 100644 --- a/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs +++ b/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs @@ -4,17 +4,21 @@ defmodule Pleroma.Repo.Migrations.FillRecipientsInActivities do def up do max = Repo.aggregate(Activity, :max, :id) + if max do IO.puts("#{max} activities") - chunks = 0..(round(max / 10_000)) + chunks = 0..round(max / 10_000) - Enum.each(chunks, fn (i) -> + Enum.each(chunks, fn i -> min = i * 10_000 max = min + 10_000 + execute(""" - update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{min} and id <= #{max}; + update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{ + min + } and id <= #{max}; """) - |> IO.inspect + |> IO.inspect() end) end end diff --git a/priv/repo/migrations/20180221210540_make_following_postgres_array.exs b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs index 5a8f8f669..34e94fdc8 100644 --- a/priv/repo/migrations/20180221210540_make_following_postgres_array.exs +++ b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs @@ -3,17 +3,18 @@ defmodule Pleroma.Repo.Migrations.MakeFollowingPostgresArray do def up do alter table(:users) do - add :following_temp, {:array, :string} + add(:following_temp, {:array, :string}) end - execute """ + execute(""" update users set following_temp = array(select jsonb_array_elements_text(following)); - """ + """) alter table(:users) do - remove :following + remove(:following) end - rename table(:users), :following_temp, to: :following + + rename(table(:users), :following_temp, to: :following) end def down, do: :ok diff --git a/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs b/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs index 234d33735..18b54411c 100644 --- a/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs +++ b/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddFollowerAddressIndexToUsers do @disable_ddl_transaction true def change do - create index(:users, [:follower_address], concurrently: true) - create index(:users, [:following], concurrently: true, using: :gin) + create(index(:users, [:follower_address], concurrently: true)) + create(index(:users, [:following], concurrently: true, using: :gin)) end end diff --git a/priv/repo/migrations/20180327174350_drop_local_index_on_activities.exs b/priv/repo/migrations/20180327174350_drop_local_index_on_activities.exs index 35c4ce62f..1574e0e00 100644 --- a/priv/repo/migrations/20180327174350_drop_local_index_on_activities.exs +++ b/priv/repo/migrations/20180327174350_drop_local_index_on_activities.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.DropLocalIndexOnActivities do use Ecto.Migration def change do - drop_if_exists index(:users, [:local]) + drop_if_exists(index(:users, [:local])) end end diff --git a/priv/repo/migrations/20180327175831_actually_drop_local_index.exs b/priv/repo/migrations/20180327175831_actually_drop_local_index.exs index 7556336ed..3d52c7c80 100644 --- a/priv/repo/migrations/20180327175831_actually_drop_local_index.exs +++ b/priv/repo/migrations/20180327175831_actually_drop_local_index.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Repo.Migrations.ActuallyDropLocalIndex do use Ecto.Migration def change do - create_if_not_exists index(:users, [:local]) - drop_if_exists index("activities", :local) + create_if_not_exists(index(:users, [:local])) + drop_if_exists(index("activities", :local)) end end diff --git a/priv/repo/migrations/20180429094642_create_lists.exs b/priv/repo/migrations/20180429094642_create_lists.exs index 9d3ce50b3..e1eb7e426 100644 --- a/priv/repo/migrations/20180429094642_create_lists.exs +++ b/priv/repo/migrations/20180429094642_create_lists.exs @@ -3,13 +3,13 @@ defmodule Pleroma.Repo.Migrations.CreateLists do def change do create_if_not_exists table(:lists) do - add :user_id, references(:users, on_delete: :delete_all) - add :title, :string - add :following, {:array, :string} + add(:user_id, references(:users, on_delete: :delete_all)) + add(:title, :string) + add(:following, {:array, :string}) timestamps() end - create_if_not_exists index(:lists, [:user_id]) + create_if_not_exists(index(:lists, [:user_id])) end end diff --git a/priv/repo/migrations/20180513104714_modify_activity_index.exs b/priv/repo/migrations/20180513104714_modify_activity_index.exs index 2df530839..ec0efa238 100644 --- a/priv/repo/migrations/20180513104714_modify_activity_index.exs +++ b/priv/repo/migrations/20180513104714_modify_activity_index.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.ModifyActivityIndex do @disable_ddl_transaction true def change do - create index(:activities, ["id desc nulls last", "local"], concurrently: true) - drop_if_exists index(:activities, ["id desc nulls last"]) + create(index(:activities, ["id desc nulls last", "local"], concurrently: true)) + drop_if_exists(index(:activities, ["id desc nulls last"])) end end diff --git a/priv/repo/migrations/20180516144508_add_trigram_extension.exs b/priv/repo/migrations/20180516144508_add_trigram_extension.exs index f2f0fca86..ff0710f84 100644 --- a/priv/repo/migrations/20180516144508_add_trigram_extension.exs +++ b/priv/repo/migrations/20180516144508_add_trigram_extension.exs @@ -4,8 +4,15 @@ defmodule Pleroma.Repo.Migrations.AddTrigramExtension do def up do Logger.warn("ATTENTION ATTENTION ATTENTION\n") - Logger.warn("This will try to create the pg_trgm extension on your database. If your database user does NOT have the necessary rights, you will have to do it manually and re-run the migrations.\nYou can probably do this by running the following:\n") - Logger.warn("sudo -u postgres psql pleroma_dev -c \"create extension if not exists pg_trgm\"\n") + + Logger.warn( + "This will try to create the pg_trgm extension on your database. If your database user does NOT have the necessary rights, you will have to do it manually and re-run the migrations.\nYou can probably do this by running the following:\n" + ) + + Logger.warn( + "sudo -u postgres psql pleroma_dev -c \"create extension if not exists pg_trgm\"\n" + ) + execute("create extension if not exists pg_trgm") end diff --git a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs index 58622a87e..0713a7297 100644 --- a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs +++ b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs @@ -2,6 +2,8 @@ defmodule Pleroma.Repo.Migrations.CreateUserTrigramIndex do use Ecto.Migration def change do - create_if_not_exists index(:users, ["(nickname || name) gist_trgm_ops"], name: :users_trigram_index, using: :gist) + create_if_not_exists( + index(:users, ["(nickname || name) gist_trgm_ops"], name: :users_trigram_index, using: :gist) + ) end end diff --git a/priv/repo/migrations/20180530123448_add_list_follow_index.exs b/priv/repo/migrations/20180530123448_add_list_follow_index.exs index 86b8de30a..57f8d478f 100644 --- a/priv/repo/migrations/20180530123448_add_list_follow_index.exs +++ b/priv/repo/migrations/20180530123448_add_list_follow_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddListFollowIndex do use Ecto.Migration def change do - create_if_not_exists index(:lists, [:following]) + create_if_not_exists(index(:lists, [:following])) end end diff --git a/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs b/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs index 9831a1b82..07b3f2875 100644 --- a/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs +++ b/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs @@ -3,6 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateApidHostExtractionIndex do @disable_ddl_transaction true def change do - create index(:activities, ["(split_part(actor, '/', 3))"], concurrently: true, name: :activities_hosts) + create( + index(:activities, ["(split_part(actor, '/', 3))"], + concurrently: true, + name: :activities_hosts + ) + ) end end diff --git a/priv/repo/migrations/20180612110515_create_user_invite_tokens.exs b/priv/repo/migrations/20180612110515_create_user_invite_tokens.exs index faee379f0..a75ff2a51 100644 --- a/priv/repo/migrations/20180612110515_create_user_invite_tokens.exs +++ b/priv/repo/migrations/20180612110515_create_user_invite_tokens.exs @@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.CreateUserInviteTokens do def change do create_if_not_exists table(:user_invite_tokens) do - add :token, :string - add :used, :boolean, default: false + add(:token, :string) + add(:used, :boolean, default: false) timestamps() end diff --git a/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs b/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs index 1fee6fd7a..c8a0e60a0 100644 --- a/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs +++ b/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs @@ -3,6 +3,11 @@ defmodule Pleroma.Repo.Migrations.CreateActivitiesInReplyToIndex do @disable_ddl_transaction true def change do - create index(:activities, ["(data->'object'->>'inReplyTo')"], concurrently: true, name: :activities_in_reply_to) + create( + index(:activities, ["(data->'object'->>'inReplyTo')"], + concurrently: true, + name: :activities_in_reply_to + ) + ) end end diff --git a/priv/repo/migrations/20180813003722_create_filters.exs b/priv/repo/migrations/20180813003722_create_filters.exs index 541cf46a1..7803558df 100644 --- a/priv/repo/migrations/20180813003722_create_filters.exs +++ b/priv/repo/migrations/20180813003722_create_filters.exs @@ -3,18 +3,21 @@ defmodule Pleroma.Repo.Migrations.CreateFilters do def change do create_if_not_exists table(:filters) do - add :user_id, references(:users, on_delete: :delete_all) - add :filter_id, :integer - add :hide, :boolean - add :phrase, :string - add :context, {:array, :string} - add :expires_at, :utc_datetime - add :whole_word, :boolean + add(:user_id, references(:users, on_delete: :delete_all)) + add(:filter_id, :integer) + add(:hide, :boolean) + add(:phrase, :string) + add(:context, {:array, :string}) + add(:expires_at, :utc_datetime) + add(:whole_word, :boolean) timestamps() end - create_if_not_exists index(:filters, [:user_id]) - create_if_not_exists index(:filters, [:phrase], where: "hide = true", name: :hided_phrases_index) + create_if_not_exists(index(:filters, [:user_id])) + + create_if_not_exists( + index(:filters, [:phrase], where: "hide = true", name: :hided_phrases_index) + ) end end diff --git a/priv/repo/migrations/20180829082446_add_recipients_to_and_cc_fields_to_activities.exs b/priv/repo/migrations/20180829082446_add_recipients_to_and_cc_fields_to_activities.exs index af9d521c0..481986039 100644 --- a/priv/repo/migrations/20180829082446_add_recipients_to_and_cc_fields_to_activities.exs +++ b/priv/repo/migrations/20180829082446_add_recipients_to_and_cc_fields_to_activities.exs @@ -3,11 +3,11 @@ defmodule Pleroma.Repo.Migrations.AddRecipientsToAndCcFieldsToActivities do def change do alter table(:activities) do - add :recipients_to, {:array, :string} - add :recipients_cc, {:array, :string} + add(:recipients_to, {:array, :string}) + add(:recipients_cc, {:array, :string}) end - create_if_not_exists index(:activities, [:recipients_to], using: :gin) - create_if_not_exists index(:activities, [:recipients_cc], using: :gin) + create_if_not_exists(index(:activities, [:recipients_to], using: :gin)) + create_if_not_exists(index(:activities, [:recipients_cc], using: :gin)) end end diff --git a/priv/repo/migrations/20180829182612_activities_add_to_cc_indices.exs b/priv/repo/migrations/20180829182612_activities_add_to_cc_indices.exs index 9d31f6779..1f9f97861 100644 --- a/priv/repo/migrations/20180829182612_activities_add_to_cc_indices.exs +++ b/priv/repo/migrations/20180829182612_activities_add_to_cc_indices.exs @@ -2,7 +2,12 @@ defmodule Pleroma.Repo.Migrations.ActivitiesAddToCcIndices do use Ecto.Migration def change do - create_if_not_exists index(:activities, ["(data->'to')"], name: :activities_to_index, using: :gin) - create_if_not_exists index(:activities, ["(data->'cc')"], name: :activities_cc_index, using: :gin) + create_if_not_exists( + index(:activities, ["(data->'to')"], name: :activities_to_index, using: :gin) + ) + + create_if_not_exists( + index(:activities, ["(data->'cc')"], name: :activities_cc_index, using: :gin) + ) end end diff --git a/priv/repo/migrations/20180829183529_remove_recipients_to_and_cc_fields_from_activities.exs b/priv/repo/migrations/20180829183529_remove_recipients_to_and_cc_fields_from_activities.exs index 017ef161f..65576b8d5 100644 --- a/priv/repo/migrations/20180829183529_remove_recipients_to_and_cc_fields_from_activities.exs +++ b/priv/repo/migrations/20180829183529_remove_recipients_to_and_cc_fields_from_activities.exs @@ -3,15 +3,15 @@ defmodule Pleroma.Repo.Migrations.RemoveRecipientsToAndCcFieldsFromActivities do def up do alter table(:activities) do - remove :recipients_to - remove :recipients_cc + remove(:recipients_to) + remove(:recipients_cc) end end def down do alter table(:activities) do - add :recipients_to, {:array, :string} - add :recipients_cc, {:array, :string} + add(:recipients_to, {:array, :string}) + add(:recipients_cc, {:array, :string}) end end end diff --git a/priv/repo/migrations/20180903114437_users_add_is_moderator_index.exs b/priv/repo/migrations/20180903114437_users_add_is_moderator_index.exs index adce28bdf..cbe79de05 100644 --- a/priv/repo/migrations/20180903114437_users_add_is_moderator_index.exs +++ b/priv/repo/migrations/20180903114437_users_add_is_moderator_index.exs @@ -2,6 +2,8 @@ defmodule Pleroma.Repo.Migrations.UsersAddIsModeratorIndex do use Ecto.Migration def change do - create_if_not_exists index(:users, ["(info->'is_moderator')"], name: :users_is_moderator_index, using: :gin) + create_if_not_exists( + index(:users, ["(info->'is_moderator')"], name: :users_is_moderator_index, using: :gin) + ) end end diff --git a/priv/repo/migrations/20180918182427_create_push_subscriptions.exs b/priv/repo/migrations/20180918182427_create_push_subscriptions.exs index 36bdf322a..c1b55d018 100644 --- a/priv/repo/migrations/20180918182427_create_push_subscriptions.exs +++ b/priv/repo/migrations/20180918182427_create_push_subscriptions.exs @@ -3,16 +3,16 @@ defmodule Pleroma.Repo.Migrations.CreatePushSubscriptions do def change do create_if_not_exists table("push_subscriptions") do - add :user_id, references("users", on_delete: :delete_all) - add :token_id, references("oauth_tokens", on_delete: :delete_all) - add :endpoint, :string - add :key_p256dh, :string - add :key_auth, :string - add :data, :map + add(:user_id, references("users", on_delete: :delete_all)) + add(:token_id, references("oauth_tokens", on_delete: :delete_all)) + add(:endpoint, :string) + add(:key_p256dh, :string) + add(:key_auth, :string) + add(:data, :map) timestamps() end - create_if_not_exists index("push_subscriptions", [:user_id, :token_id], unique: true) + create_if_not_exists(index("push_subscriptions", [:user_id, :token_id], unique: true)) end end diff --git a/priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs b/priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs index 815177e05..16605cf7b 100644 --- a/priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs +++ b/priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.UsersAddLastRefreshedAt do def change do alter table(:users) do - add :last_refreshed_at, :naive_datetime_usec + add(:last_refreshed_at, :naive_datetime_usec) end end end diff --git a/priv/repo/migrations/20181206125616_add_tags_to_users.exs b/priv/repo/migrations/20181206125616_add_tags_to_users.exs index 7d42a0fba..a46c0fc35 100644 --- a/priv/repo/migrations/20181206125616_add_tags_to_users.exs +++ b/priv/repo/migrations/20181206125616_add_tags_to_users.exs @@ -3,9 +3,9 @@ defmodule Pleroma.Repo.Migrations.AddTagsToUsers do def change do alter table(:users) do - add :tags, {:array, :string} + add(:tags, {:array, :string}) end - create_if_not_exists index(:users, [:tags], using: :gin) + create_if_not_exists(index(:users, [:tags], using: :gin)) end end diff --git a/priv/repo/migrations/20181214121049_add_bookmarks_to_users.exs b/priv/repo/migrations/20181214121049_add_bookmarks_to_users.exs index 55e97ae0e..6228f1bad 100644 --- a/priv/repo/migrations/20181214121049_add_bookmarks_to_users.exs +++ b/priv/repo/migrations/20181214121049_add_bookmarks_to_users.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddBookmarksToUsers do def change do alter table(:users) do - add :bookmarks, {:array, :string}, null: false, default: [] + add(:bookmarks, {:array, :string}, null: false, default: []) end end end diff --git a/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs b/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs index a5b4c543d..c58d829af 100644 --- a/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs +++ b/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs @@ -16,32 +16,34 @@ defmodule Pleroma.Repo.Migrations.UsersAndActivitiesFlakeId do # Old serial int ids are transformed to 128bits with extra padding. # The application (in `Pleroma.FlakeId`) handles theses IDs properly as integers; to keep compatibility # with previously issued ids. - #execute "update activities set external_id = CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid);" - #execute "update users set external_id = CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid);" + # execute "update activities set external_id = CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid);" + # execute "update users set external_id = CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid);" clippy = start_clippy_heartbeats() # Lock both tables to avoid a running server to meddling with our transaction - execute "LOCK TABLE activities;" - execute "LOCK TABLE users;" + execute("LOCK TABLE activities;") + execute("LOCK TABLE users;") - execute """ + execute(""" ALTER TABLE activities DROP CONSTRAINT activities_pkey CASCADE, ALTER COLUMN id DROP default, ALTER COLUMN id SET DATA TYPE uuid USING CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid), ADD PRIMARY KEY (id); - """ + """) - execute """ + execute(""" ALTER TABLE users DROP CONSTRAINT users_pkey CASCADE, ALTER COLUMN id DROP default, ALTER COLUMN id SET DATA TYPE uuid USING CAST( LPAD( TO_HEX(id), 32, '0' ) AS uuid), ADD PRIMARY KEY (id); - """ + """) - execute "UPDATE users SET info = jsonb_set(info, '{pinned_activities}', array_to_json(ARRAY(select jsonb_array_elements_text(info->'pinned_activities')))::jsonb);" + execute( + "UPDATE users SET info = jsonb_set(info, '{pinned_activities}', array_to_json(ARRAY(select jsonb_array_elements_text(info->'pinned_activities')))::jsonb);" + ) # Fkeys: # Activities - Referenced by: @@ -56,18 +58,19 @@ defmodule Pleroma.Repo.Migrations.UsersAndActivitiesFlakeId do # TABLE "push_subscriptions" CONSTRAINT "push_subscriptions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE # TABLE "websub_client_subscriptions" CONSTRAINT "websub_client_subscriptions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) - execute """ + execute(""" ALTER TABLE notifications ALTER COLUMN activity_id SET DATA TYPE uuid USING CAST( LPAD( TO_HEX(activity_id), 32, '0' ) AS uuid), ADD CONSTRAINT notifications_activity_id_fkey FOREIGN KEY (activity_id) REFERENCES activities(id) ON DELETE CASCADE; - """ + """) - for table <- ~w(notifications filters lists oauth_authorizations oauth_tokens password_reset_tokens push_subscriptions websub_client_subscriptions) do - execute """ + for table <- + ~w(notifications filters lists oauth_authorizations oauth_tokens password_reset_tokens push_subscriptions websub_client_subscriptions) do + execute(""" ALTER TABLE #{table} ALTER COLUMN user_id SET DATA TYPE uuid USING CAST( LPAD( TO_HEX(user_id), 32, '0' ) AS uuid), ADD CONSTRAINT #{table}_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; - """ + """) end flush() @@ -78,41 +81,50 @@ defmodule Pleroma.Repo.Migrations.UsersAndActivitiesFlakeId do def down, do: :ok defp start_clippy_heartbeats() do - count = from(a in "activities", select: count(a.id)) |> Repo.one! + count = from(a in "activities", select: count(a.id)) |> Repo.one!() if count > 5000 do heartbeat_interval = :timer.minutes(2) + :timer.seconds(30) - all_tips = Clippy.tips() ++ [ - "The migration is still running, maybe it's time for another “tea”?", - "Happy rabbits practice a cute behavior known as a\n“binky:” they jump up in the air\nand twist\nand spin around!", - "Nothing and everything.\n\nI still work.", - "Pleroma runs on a Raspberry Pi!\n\n … but this migration will take forever if you\nactually run on a raspberry pi", - "Status? Stati? Post? Note? Toot?\nRepeat? Reboost? Boost? Retweet? Retoot??\n\nI-I'm confused.", - ] - - heartbeat = fn(heartbeat, runs, all_tips, tips) -> - tips = if Integer.is_even(runs) do - tips = if tips == [], do: all_tips, else: tips - [tip | tips] = Enum.shuffle(tips) - Clippy.puts(tip) - tips - else - IO.puts "\n -- #{DateTime.to_string(DateTime.utc_now())} Migration still running, please wait…\n" - tips - end + + all_tips = + Clippy.tips() ++ + [ + "The migration is still running, maybe it's time for another “tea”?", + "Happy rabbits practice a cute behavior known as a\n“binky:” they jump up in the air\nand twist\nand spin around!", + "Nothing and everything.\n\nI still work.", + "Pleroma runs on a Raspberry Pi!\n\n … but this migration will take forever if you\nactually run on a raspberry pi", + "Status? Stati? Post? Note? Toot?\nRepeat? Reboost? Boost? Retweet? Retoot??\n\nI-I'm confused." + ] + + heartbeat = fn heartbeat, runs, all_tips, tips -> + tips = + if Integer.is_even(runs) do + tips = if tips == [], do: all_tips, else: tips + [tip | tips] = Enum.shuffle(tips) + Clippy.puts(tip) + tips + else + IO.puts( + "\n -- #{DateTime.to_string(DateTime.utc_now())} Migration still running, please wait…\n" + ) + + tips + end + :timer.sleep(heartbeat_interval) heartbeat.(heartbeat, runs + 1, all_tips, tips) end - Clippy.puts [ + Clippy.puts([ [:red, :bright, "It looks like you are running an older instance!"], [""], [:bright, "This migration may take a long time", :reset, " -- so you probably should"], ["go drink a cofe, or a tea, or a beer, a whiskey, a vodka,"], ["while it runs to deal with your temporary fediverse pause!"] - ] + ]) + :timer.sleep(heartbeat_interval) - spawn_link(fn() -> heartbeat.(heartbeat, 1, all_tips, []) end) + spawn_link(fn -> heartbeat.(heartbeat, 1, all_tips, []) end) end end @@ -120,8 +132,7 @@ defmodule Pleroma.Repo.Migrations.UsersAndActivitiesFlakeId do if pid do Process.unlink(pid) Process.exit(pid, :kill) - Clippy.puts [[:green, :bright, "Hurray!!", "", "", "Migration completed!"]] + Clippy.puts([[:green, :bright, "Hurray!!", "", "", "Migration completed!"]]) end end - end diff --git a/priv/repo/migrations/20190109152453_add_visibility_function.exs b/priv/repo/migrations/20190109152453_add_visibility_function.exs index b6a4e752b..43d1074aa 100644 --- a/priv/repo/migrations/20190109152453_add_visibility_function.exs +++ b/priv/repo/migrations/20190109152453_add_visibility_function.exs @@ -43,6 +43,8 @@ defmodule Pleroma.Repo.Migrations.AddVisibilityFunction do ) ) - execute("drop function if exists activity_visibility(actor varchar, recipients varchar[], data jsonb)") + execute( + "drop function if exists activity_visibility(actor varchar, recipients varchar[], data jsonb)" + ) end end diff --git a/priv/repo/migrations/20190115085500_create_user_fts_index.exs b/priv/repo/migrations/20190115085500_create_user_fts_index.exs index cff975318..0c0c512d3 100644 --- a/priv/repo/migrations/20190115085500_create_user_fts_index.exs +++ b/priv/repo/migrations/20190115085500_create_user_fts_index.exs @@ -2,16 +2,18 @@ defmodule Pleroma.Repo.Migrations.CreateUserFtsIndex do use Ecto.Migration def change do - create_if_not_exists index( - :users, - [ - """ - (setweight(to_tsvector('simple', regexp_replace(nickname, '\\W', ' ', 'g')), 'A') || - setweight(to_tsvector('simple', regexp_replace(coalesce(name, ''), '\\W', ' ', 'g')), 'B')) - """ - ], - name: :users_fts_index, - using: :gin - ) + create_if_not_exists( + index( + :users, + [ + """ + (setweight(to_tsvector('simple', regexp_replace(nickname, '\\W', ' ', 'g')), 'A') || + setweight(to_tsvector('simple', regexp_replace(coalesce(name, ''), '\\W', ' ', 'g')), 'B')) + """ + ], + name: :users_fts_index, + using: :gin + ) + ) end end diff --git a/priv/repo/migrations/20190122153157_update_activity_visibility.exs b/priv/repo/migrations/20190122153157_update_activity_visibility.exs index 30075137c..9e29571ee 100644 --- a/priv/repo/migrations/20190122153157_update_activity_visibility.exs +++ b/priv/repo/migrations/20190122153157_update_activity_visibility.exs @@ -27,10 +27,8 @@ defmodule Pleroma.Repo.Migrations.UpdateActivityVisibility do """ execute(definition) - end def down do - end end diff --git a/priv/repo/migrations/20190123092341_users_add_is_admin_index.exs b/priv/repo/migrations/20190123092341_users_add_is_admin_index.exs index 25f248c59..f42d46427 100644 --- a/priv/repo/migrations/20190123092341_users_add_is_admin_index.exs +++ b/priv/repo/migrations/20190123092341_users_add_is_admin_index.exs @@ -2,6 +2,8 @@ defmodule Pleroma.Repo.Migrations.UsersAddIsAdminIndex do use Ecto.Migration def change do - create_if_not_exists(index(:users, ["(info->'is_admin')"], name: :users_is_admin_index, using: :gin)) + create_if_not_exists( + index(:users, ["(info->'is_admin')"], name: :users_is_admin_index, using: :gin) + ) end end diff --git a/priv/repo/migrations/20190123125546_create_instances.exs b/priv/repo/migrations/20190123125546_create_instances.exs index a9b356bc3..9438736ba 100644 --- a/priv/repo/migrations/20190123125546_create_instances.exs +++ b/priv/repo/migrations/20190123125546_create_instances.exs @@ -3,13 +3,13 @@ defmodule Pleroma.Repo.Migrations.CreateInstances do def change do create_if_not_exists table(:instances) do - add :host, :string - add :unreachable_since, :naive_datetime_usec + add(:host, :string) + add(:unreachable_since, :naive_datetime_usec) timestamps() end - create_if_not_exists unique_index(:instances, [:host]) - create_if_not_exists index(:instances, [:unreachable_since]) + create_if_not_exists(unique_index(:instances, [:host])) + create_if_not_exists(index(:instances, [:unreachable_since])) end end diff --git a/priv/repo/migrations/20190124131141_update_activity_visibility_again.exs b/priv/repo/migrations/20190124131141_update_activity_visibility_again.exs index 0519a5143..a42e4cad9 100644 --- a/priv/repo/migrations/20190124131141_update_activity_visibility_again.exs +++ b/priv/repo/migrations/20190124131141_update_activity_visibility_again.exs @@ -27,11 +27,8 @@ defmodule Pleroma.Repo.Migrations.UpdateActivityVisibilityAgain do """ execute(definition) - end def down do - end - end diff --git a/priv/repo/migrations/20190127151220_add_activities_likes_index.exs b/priv/repo/migrations/20190127151220_add_activities_likes_index.exs index b1822d265..115b12491 100644 --- a/priv/repo/migrations/20190127151220_add_activities_likes_index.exs +++ b/priv/repo/migrations/20190127151220_add_activities_likes_index.exs @@ -3,6 +3,12 @@ defmodule Pleroma.Repo.Migrations.AddActivitiesLikesIndex do @disable_ddl_transaction true def change do - create index(:activities, ["((data #> '{\"object\",\"likes\"}'))"], concurrently: true, name: :activities_likes, using: :gin) + create( + index(:activities, ["((data #> '{\"object\",\"likes\"}'))"], + concurrently: true, + name: :activities_likes, + using: :gin + ) + ) end end diff --git a/priv/repo/migrations/20190203185340_split_hide_network.exs b/priv/repo/migrations/20190203185340_split_hide_network.exs index 8b7a9151b..fb677f68a 100644 --- a/priv/repo/migrations/20190203185340_split_hide_network.exs +++ b/priv/repo/migrations/20190203185340_split_hide_network.exs @@ -2,9 +2,17 @@ defmodule Pleroma.Repo.Migrations.SplitHideNetwork do use Ecto.Migration def up do - execute("UPDATE users SET info = jsonb_set(info, '{hide_network}'::text[], 'false'::jsonb) WHERE NOT(info::jsonb ? 'hide_network') AND local") - execute("UPDATE users SET info = jsonb_set(info, '{hide_followings}'::text[], info->'hide_network') WHERE local") - execute("UPDATE users SET info = jsonb_set(info, '{hide_followers}'::text[], info->'hide_network') WHERE local") + execute( + "UPDATE users SET info = jsonb_set(info, '{hide_network}'::text[], 'false'::jsonb) WHERE NOT(info::jsonb ? 'hide_network') AND local" + ) + + execute( + "UPDATE users SET info = jsonb_set(info, '{hide_followings}'::text[], info->'hide_network') WHERE local" + ) + + execute( + "UPDATE users SET info = jsonb_set(info, '{hide_followers}'::text[], info->'hide_network') WHERE local" + ) end def down do diff --git a/priv/repo/migrations/20190205114625_create_thread_mutes.exs b/priv/repo/migrations/20190205114625_create_thread_mutes.exs index baaf07253..df9eb7677 100644 --- a/priv/repo/migrations/20190205114625_create_thread_mutes.exs +++ b/priv/repo/migrations/20190205114625_create_thread_mutes.exs @@ -3,10 +3,10 @@ defmodule Pleroma.Repo.Migrations.CreateThreadMutes do def change do create_if_not_exists table(:thread_mutes) do - add :user_id, references(:users, type: :uuid, on_delete: :delete_all) - add :context, :string + add(:user_id, references(:users, type: :uuid, on_delete: :delete_all)) + add(:context, :string) end - create_if_not_exists unique_index(:thread_mutes, [:user_id, :context], name: :unique_index) + create_if_not_exists(unique_index(:thread_mutes, [:user_id, :context], name: :unique_index)) end end diff --git a/priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs b/priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs index 4efbebc4d..ad93bfce2 100644 --- a/priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs +++ b/priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs @@ -4,7 +4,7 @@ defmodule Pleroma.Repo.Migrations.AddScopeSToOAuthEntities do def change do for t <- [:oauth_authorizations, :oauth_tokens] do alter table(t) do - add :scopes, {:array, :string}, default: [], null: false + add(:scopes, {:array, :string}, default: [], null: false) end end end diff --git a/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs b/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs index 72decd401..eb6fcb012 100644 --- a/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs +++ b/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs @@ -4,14 +4,20 @@ defmodule Pleroma.Repo.Migrations.ChangeAppsScopesToVarcharArray do @alter_apps_scopes "ALTER TABLE apps ALTER COLUMN scopes" def up do - execute "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];" - execute "#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];" - execute "#{@alter_apps_scopes} SET NOT NULL;" + execute( + "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];" + ) + + execute("#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];") + execute("#{@alter_apps_scopes} SET NOT NULL;") end def down do - execute "#{@alter_apps_scopes} DROP NOT NULL;" - execute "#{@alter_apps_scopes} DROP DEFAULT;" - execute "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);" + execute("#{@alter_apps_scopes} DROP NOT NULL;") + execute("#{@alter_apps_scopes} DROP DEFAULT;") + + execute( + "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);" + ) end end diff --git a/priv/repo/migrations/20190213185600_data_migration_populate_o_auth_scopes.exs b/priv/repo/migrations/20190213185600_data_migration_populate_o_auth_scopes.exs index 7afbcbd76..ef5b35125 100644 --- a/priv/repo/migrations/20190213185600_data_migration_populate_o_auth_scopes.exs +++ b/priv/repo/migrations/20190213185600_data_migration_populate_o_auth_scopes.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.DataMigrationPopulateOAuthScopes do def up do for t <- [:oauth_authorizations, :oauth_tokens] do - execute "UPDATE #{t} SET scopes = apps.scopes FROM apps WHERE #{t}.app_id = apps.id;" + execute("UPDATE #{t} SET scopes = apps.scopes FROM apps WHERE #{t}.app_id = apps.id;") end end diff --git a/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs b/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs index d44e5096b..92ab9bd2c 100644 --- a/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs +++ b/priv/repo/migrations/20190222104808_data_migration_normalize_scopes.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.DataMigrationNormalizeScopes do def up do for t <- [:apps, :oauth_authorizations, :oauth_tokens] do - execute "UPDATE #{t} SET scopes = string_to_array(array_to_string(scopes, ' '), ' ');" + execute("UPDATE #{t} SET scopes = string_to_array(array_to_string(scopes, ' '), ' ');") end end diff --git a/priv/repo/migrations/20190301101154_add_default_tags_to_user.exs b/priv/repo/migrations/20190301101154_add_default_tags_to_user.exs index faeb8f1c6..ea0947852 100644 --- a/priv/repo/migrations/20190301101154_add_default_tags_to_user.exs +++ b/priv/repo/migrations/20190301101154_add_default_tags_to_user.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddDefaultTagsToUser do use Ecto.Migration def up do - execute "UPDATE users SET tags = array[]::varchar[] where tags IS NULL" + execute("UPDATE users SET tags = array[]::varchar[] where tags IS NULL") end def down, do: :noop diff --git a/priv/repo/migrations/20190303120636_update_user_note_counters.exs b/priv/repo/migrations/20190303120636_update_user_note_counters.exs index 54e68f7c9..95dbd012f 100644 --- a/priv/repo/migrations/20190303120636_update_user_note_counters.exs +++ b/priv/repo/migrations/20190303120636_update_user_note_counters.exs @@ -4,7 +4,7 @@ defmodule Pleroma.Repo.Migrations.UpdateUserNoteCounters do @public "https://www.w3.org/ns/activitystreams#Public" def up do - execute """ + execute(""" WITH public_note_count AS ( SELECT data->>'actor' AS actor, @@ -19,11 +19,11 @@ defmodule Pleroma.Repo.Migrations.UpdateUserNoteCounters do SET "info" = jsonb_set(u.info, '{note_count}', o.count::varchar::jsonb, true) FROM public_note_count AS o WHERE u.ap_id = o.actor - """ + """) end def down do - execute """ + execute(""" WITH public_note_count AS ( SELECT data->>'actor' AS actor, @@ -36,6 +36,6 @@ defmodule Pleroma.Repo.Migrations.UpdateUserNoteCounters do SET "info" = jsonb_set(u.info, '{note_count}', o.count::varchar::jsonb, true) FROM public_note_count AS o WHERE u.ap_id = o.actor - """ + """) end end diff --git a/priv/repo/migrations/20190315101315_create_registrations.exs b/priv/repo/migrations/20190315101315_create_registrations.exs index 34a390a93..d705a499e 100644 --- a/priv/repo/migrations/20190315101315_create_registrations.exs +++ b/priv/repo/migrations/20190315101315_create_registrations.exs @@ -3,16 +3,16 @@ defmodule Pleroma.Repo.Migrations.CreateRegistrations do def change do create_if_not_exists table(:registrations, primary_key: false) do - add :id, :uuid, primary_key: true - add :user_id, references(:users, type: :uuid, on_delete: :delete_all) - add :provider, :string - add :uid, :string - add :info, :map, default: %{} + add(:id, :uuid, primary_key: true) + add(:user_id, references(:users, type: :uuid, on_delete: :delete_all)) + add(:provider, :string) + add(:uid, :string) + add(:info, :map, default: %{}) timestamps() end - create_if_not_exists unique_index(:registrations, [:provider, :uid]) - create_if_not_exists unique_index(:registrations, [:user_id, :provider, :uid]) + create_if_not_exists(unique_index(:registrations, [:provider, :uid])) + create_if_not_exists(unique_index(:registrations, [:user_id, :provider, :uid])) end end diff --git a/priv/repo/migrations/20190325185009_create_notification_id_index.exs b/priv/repo/migrations/20190325185009_create_notification_id_index.exs index 01cb30559..7209c16a9 100644 --- a/priv/repo/migrations/20190325185009_create_notification_id_index.exs +++ b/priv/repo/migrations/20190325185009_create_notification_id_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.CreateNotificationIdIndex do use Ecto.Migration def change do - create_if_not_exists index(:notifications, ["id desc nulls last"]) + create_if_not_exists(index(:notifications, ["id desc nulls last"])) end end diff --git a/priv/repo/migrations/20190405160700_add_index_on_subscribers.exs b/priv/repo/migrations/20190405160700_add_index_on_subscribers.exs index 460dafb1b..bbf47f72c 100644 --- a/priv/repo/migrations/20190405160700_add_index_on_subscribers.exs +++ b/priv/repo/migrations/20190405160700_add_index_on_subscribers.exs @@ -3,6 +3,12 @@ defmodule Pleroma.Repo.Migrations.AddIndexOnSubscribers do @disable_ddl_transaction true def change do - create index(:users, ["(info->'subscribers')"], name: :users_subscribers_index, using: :gin, concurrently: true) + create( + index(:users, ["(info->'subscribers')"], + name: :users_subscribers_index, + using: :gin, + concurrently: true + ) + ) end end diff --git a/priv/repo/migrations/20190408123347_create_conversations.exs b/priv/repo/migrations/20190408123347_create_conversations.exs index 7b7d89da7..d75459e82 100644 --- a/priv/repo/migrations/20190408123347_create_conversations.exs +++ b/priv/repo/migrations/20190408123347_create_conversations.exs @@ -19,8 +19,8 @@ defmodule Pleroma.Repo.Migrations.CreateConversations do timestamps() end - create_if_not_exists index(:conversation_participations, [:conversation_id]) - create_if_not_exists unique_index(:conversation_participations, [:user_id, :conversation_id]) - create_if_not_exists unique_index(:conversations, [:ap_id]) + create_if_not_exists(index(:conversation_participations, [:conversation_id])) + create_if_not_exists(unique_index(:conversation_participations, [:user_id, :conversation_id])) + create_if_not_exists(unique_index(:conversations, [:ap_id])) end end diff --git a/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs b/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs index b5ca2fc0f..e22c6e57d 100644 --- a/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs +++ b/priv/repo/migrations/20190410152859_add_participation_updated_at_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddParticipationUpdatedAtIndex do use Ecto.Migration def change do - create_if_not_exists index(:conversation_participations, ["updated_at desc"]) + create_if_not_exists(index(:conversation_participations, ["updated_at desc"])) end end diff --git a/priv/repo/migrations/20190411094120_add_index_on_user_info_deactivated.exs b/priv/repo/migrations/20190411094120_add_index_on_user_info_deactivated.exs index c19427f12..374e2323d 100644 --- a/priv/repo/migrations/20190411094120_add_index_on_user_info_deactivated.exs +++ b/priv/repo/migrations/20190411094120_add_index_on_user_info_deactivated.exs @@ -2,6 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddIndexOnUserInfoDeactivated do use Ecto.Migration def change do - create_if_not_exists(index(:users, ["(info->'deactivated')"], name: :users_deactivated_index, using: :gin)) + create_if_not_exists( + index(:users, ["(info->'deactivated')"], name: :users_deactivated_index, using: :gin) + ) end end diff --git a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs index ce4590954..f3928a149 100644 --- a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs +++ b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs @@ -18,7 +18,7 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do |> Enum.each(fn %{id: user_id, bookmarks: bookmarks} -> Enum.each(bookmarks, fn ap_id -> activity = Activity.get_create_by_object_ap_id(ap_id) - unless is_nil(activity), do: {:ok, _} = Bookmark.create(user_id, activity.id) + unless is_nil(activity), do: {:ok, _} = Bookmark.create(user_id, activity.id) end) end) @@ -29,7 +29,7 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do def down do alter table(:users) do - add :bookmarks, {:array, :string}, null: false, default: [] + add(:bookmarks, {:array, :string}, null: false, default: []) end end end diff --git a/priv/repo/migrations/20190501125843_add_fts_index_to_objects.exs b/priv/repo/migrations/20190501125843_add_fts_index_to_objects.exs index d4de51691..41630bace 100644 --- a/priv/repo/migrations/20190501125843_add_fts_index_to_objects.exs +++ b/priv/repo/migrations/20190501125843_add_fts_index_to_objects.exs @@ -2,7 +2,18 @@ defmodule Pleroma.Repo.Migrations.AddFTSIndexToObjects do use Ecto.Migration def change do - drop_if_exists index(:activities, ["(to_tsvector('english', data->'object'->>'content'))"], using: :gin, name: :activities_fts) - create_if_not_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts) + drop_if_exists( + index(:activities, ["(to_tsvector('english', data->'object'->>'content'))"], + using: :gin, + name: :activities_fts + ) + ) + + create_if_not_exists( + index(:objects, ["(to_tsvector('english', data->>'content'))"], + using: :gin, + name: :objects_fts + ) + ) end end diff --git a/priv/repo/migrations/20190511191044_set_default_state_to_reports.exs b/priv/repo/migrations/20190511191044_set_default_state_to_reports.exs index 0d3d253b6..ab1351d56 100644 --- a/priv/repo/migrations/20190511191044_set_default_state_to_reports.exs +++ b/priv/repo/migrations/20190511191044_set_default_state_to_reports.exs @@ -2,18 +2,18 @@ defmodule Pleroma.Repo.Migrations.SetDefaultStateToReports do use Ecto.Migration def up do - execute """ + execute(""" UPDATE activities AS a SET data = jsonb_set(data, '{state}', '"open"', true) WHERE data->>'type' = 'Flag' - """ + """) end def down do - execute """ + execute(""" UPDATE activities AS a SET data = data #- '{state}' WHERE data->>'type' = 'Flag' - """ + """) end end diff --git a/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs b/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs index 246b70cfb..8135ab178 100644 --- a/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs +++ b/priv/repo/migrations/20190513175809_change_hide_column_in_filter_table.exs @@ -3,13 +3,13 @@ defmodule Pleroma.Repo.Migrations.ChangeHideColumnInFilterTable do def up do alter table(:filters) do - modify :hide, :boolean, default: false + modify(:hide, :boolean, default: false) end end def down do alter table(:filters) do - modify :hide, :boolean + modify(:hide, :boolean) end end end diff --git a/priv/repo/migrations/20190603162018_add_object_in_reply_to_index.exs b/priv/repo/migrations/20190603162018_add_object_in_reply_to_index.exs index df4ac7782..faed5e31b 100644 --- a/priv/repo/migrations/20190603162018_add_object_in_reply_to_index.exs +++ b/priv/repo/migrations/20190603162018_add_object_in_reply_to_index.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddObjectInReplyToIndex do use Ecto.Migration def change do - create index(:objects, ["(data->>'inReplyTo')"], name: :objects_in_reply_to_index) + create(index(:objects, ["(data->>'inReplyTo')"], name: :objects_in_reply_to_index)) end end diff --git a/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs b/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs index 93d57a249..9ba95917c 100644 --- a/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs +++ b/priv/repo/migrations/20190603173419_add_tag_index_to_objects.exs @@ -2,7 +2,10 @@ defmodule Pleroma.Repo.Migrations.AddTagIndexToObjects do use Ecto.Migration def change do - drop_if_exists index(:activities, ["(data #> '{\"object\",\"tag\"}')"], using: :gin, name: :activities_tags) - create_if_not_exists index(:objects, ["(data->'tag')"], using: :gin, name: :objects_tags) + drop_if_exists( + index(:activities, ["(data #> '{\"object\",\"tag\"}')"], using: :gin, name: :activities_tags) + ) + + create_if_not_exists(index(:objects, ["(data->'tag')"], using: :gin, name: :objects_tags)) end end diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs index b717cab2e..bc4e828cc 100644 --- a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs +++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -3,6 +3,8 @@ defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do alias Pleroma.User def change do - execute("update users set info = jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true") + execute( + "update users set info = jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true" + ) end end diff --git a/priv/repo/migrations/20190801154554_create_conversation_participation_recipient_ships.exs b/priv/repo/migrations/20190801154554_create_conversation_participation_recipient_ships.exs index c6e3469d5..59cbe25ad 100644 --- a/priv/repo/migrations/20190801154554_create_conversation_participation_recipient_ships.exs +++ b/priv/repo/migrations/20190801154554_create_conversation_participation_recipient_ships.exs @@ -7,7 +7,7 @@ defmodule Pleroma.Repo.Migrations.CreateConversationParticipationRecipientShips add(:participation_id, references(:conversation_participations, on_delete: :delete_all)) end - create_if_not_exists index(:conversation_participation_recipient_ships, [:user_id]) - create_if_not_exists index(:conversation_participation_recipient_ships, [:participation_id]) + create_if_not_exists(index(:conversation_participation_recipient_ships, [:user_id])) + create_if_not_exists(index(:conversation_participation_recipient_ships, [:participation_id])) end end diff --git a/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs b/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs index 13f3d6e83..c410dcdc2 100644 --- a/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs +++ b/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs @@ -2,6 +2,6 @@ defmodule Pleroma.Repo.Migrations.AddLikesIndexToObjects do use Ecto.Migration def change do - create_if_not_exists index(:objects, ["(data->'likes')"], using: :gin, name: :objects_likes) + create_if_not_exists(index(:objects, ["(data->'likes')"], using: :gin, name: :objects_likes)) end end diff --git a/priv/repo/migrations/20190912065617_create_deliveries.exs b/priv/repo/migrations/20190912065617_create_deliveries.exs index 79071a799..ac2832a77 100644 --- a/priv/repo/migrations/20190912065617_create_deliveries.exs +++ b/priv/repo/migrations/20190912065617_create_deliveries.exs @@ -6,7 +6,8 @@ defmodule Pleroma.Repo.Migrations.CreateDeliveries do add(:object_id, references(:objects, type: :id), null: false) add(:user_id, references(:users, type: :uuid, on_delete: :delete_all), null: false) end - create_if_not_exists index(:deliveries, :object_id, name: :deliveries_object_id) + + create_if_not_exists(index(:deliveries, :object_id, name: :deliveries_object_id)) create_if_not_exists(unique_index(:deliveries, [:user_id, :object_id])) end end diff --git a/priv/repo/migrations/20190929201536_drop_subscription_if_exists.exs b/priv/repo/migrations/20190929201536_drop_subscription_if_exists.exs index bbf70f78b..8bd2a98bb 100644 --- a/priv/repo/migrations/20190929201536_drop_subscription_if_exists.exs +++ b/priv/repo/migrations/20190929201536_drop_subscription_if_exists.exs @@ -2,7 +2,6 @@ defmodule Pleroma.Repo.Migrations.DropSubscriptionIfExists do use Ecto.Migration def change do - end def up do @@ -10,6 +9,7 @@ defmodule Pleroma.Repo.Migrations.DropSubscriptionIfExists do drop_if_exists(index(:subscription_notifications, ["id desc nulls last"])) drop_if_exists(table(:subscription_notifications)) end + def down do :ok end diff --git a/priv/repo/migrations/20191006123824_add_keys_column.exs b/priv/repo/migrations/20191006123824_add_keys_column.exs index b6c615646..4114ba416 100644 --- a/priv/repo/migrations/20191006123824_add_keys_column.exs +++ b/priv/repo/migrations/20191006123824_add_keys_column.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.AddKeysColumn do def change do alter table("users") do - add_if_not_exists :keys, :text + add_if_not_exists(:keys, :text) end end end diff --git a/priv/repo/migrations/20191006135457_move_keys_to_separate_column.exs b/priv/repo/migrations/20191006135457_move_keys_to_separate_column.exs index 504dde53a..cb8d4ae9e 100644 --- a/priv/repo/migrations/20191006135457_move_keys_to_separate_column.exs +++ b/priv/repo/migrations/20191006135457_move_keys_to_separate_column.exs @@ -2,6 +2,9 @@ defmodule Pleroma.Repo.Migrations.MoveKeysToSeparateColumn do use Ecto.Migration def change do - execute("update users set keys = info->>'keys' where local", "update users set info = jsonb_set(info, '{keys}'::text[], to_jsonb(keys)) where local") + execute( + "update users set keys = info->>'keys' where local", + "update users set info = jsonb_set(info, '{keys}'::text[], to_jsonb(keys)) where local" + ) end end -- 2.45.2