From 73df4b70a8f7e03f8aa5b23c2e7ffe6afcc8462c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 22 Feb 2019 14:18:52 +0100 Subject: [PATCH] Fix mix format and format migrations too Signed-off-by: Thomas Citharel Fix credo warnings Signed-off-by: Thomas Citharel Show elixir version Signed-off-by: Thomas Citharel Also lint migrations Signed-off-by: Thomas Citharel Reset allow failure to false Signed-off-by: Thomas Citharel --- .formatter.exs | 2 +- .gitlab-ci.yml | 3 +- lib/mobilizon_web/api/search.ex | 7 +- .../20180109165738_create_accounts.exs | 21 ++- .../20180109170315_create_users.exs | 10 +- .../20180110091747_create_categories.exs | 9 +- .../20180110092400_create_addresses.exs | 17 ++- .../20180110092500_create_groups.exs | 17 ++- .../20180110092600_create_events.exs | 37 +++--- .../migrations/20180110093905_create_tags.exs | 7 +- .../20180110093906_create_events_tags.exs | 4 +- .../20180110094301_create_participants.exs | 11 +- .../20180110094502_create_event_requests.exs | 11 +- .../20180110095317_create_members.exs | 11 +- .../20180110095515_create_group_requests.exs | 11 +- .../20180112100000_create_tracks.exs | 9 +- .../20180112105354_create_sessions.exs | 27 ++-- .../migrations/20180430071244_remove_uri.exs | 8 +- ...20180515091106_add_url_field_to_events.exs | 4 +- .../20180515100237_create_comments.exs | 12 +- ...timestamps_to_date_time_with_time_zone.exs | 8 +- ...local_attribute_to_events_and_comments.exs | 8 +- ...80517100700_move_from_account_to_actor.exs | 121 +++++++++--------- .../20180522133844_add_bots_table.exs | 10 +- ...0125159_add_avatar_and_banner_to_actor.exs | 8 +- ...0152323_make_actor_public_key_nullable.exs | 4 +- .../20180530170808_add_uuid_id_to_events.exs | 4 +- ...31162301_add_approved_status_to_member.exs | 4 +- .../20180607095732_add_uuid_to_comments.exs | 4 +- ...4094653_make_shared_inbox_url_nullable.exs | 4 +- ...on_public_private_key_into_keys_column.exs | 9 +- ...ibuted_to_field_to_events_and_comments.exs | 8 +- ...28091920_add-user-confirm-email-fields.exs | 17 ++- ...8130746_add-user-password-reset-fields.exs | 15 ++- ...28142835_revert_alter_event_timestamps.exs | 8 +- .../20180702150922_add_address_type.exs | 24 ++-- .../20180702154630_remove_slug_for_event.exs | 2 +- ...8_alter_events_set_description_as_text.exs | 4 +- ...54152_allow_multiple_accounts_for_user.exs | 8 +- ...80802133951_make_follower_table_unique.exs | 12 +- ...180816093446_add_primary_key_to_member.exs | 15 ++- ...021161324_add_default_actor_user_field.exs | 4 +- ...20181108165151_fix_comments_references.exs | 16 +-- .../20181203092128_change_actors_indexes.exs | 30 +++-- .../20190103150805_fix_event_visibility.exs | 15 ++- .../20190114162055_remove_address_type.exs | 6 +- ...125143718_group_delete_members_cascade.exs | 8 +- ...plit_event_visibility_and_join_options.exs | 30 +++-- ...07134142_move_participant_role_to_enum.exs | 26 ++-- .../20190208141700_tags_relations.exs | 21 +-- .../20190214100858_drop_datetimetz.exs | 2 +- priv/repo/seeds.exs | 1 - 52 files changed, 370 insertions(+), 324 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 2bed17cc0..023562bf3 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,3 +1,3 @@ [ - inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: ["{mix,.formatter}.exs", "{config,lib,test,priv}/**/*.{ex,exs}"] ] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 802952f40..e778cbfaf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,8 +41,9 @@ elixir_check: before_script: - mix deps.get script: - - mix format --check-formatted --dry-run - mix credo list + - mix format --check-formatted --dry-run + - mix hex.outdated cache: paths: - deps diff --git a/lib/mobilizon_web/api/search.ex b/lib/mobilizon_web/api/search.ex index 067d30764..0b7c5c7e4 100644 --- a/lib/mobilizon_web/api/search.ex +++ b/lib/mobilizon_web/api/search.ex @@ -1,4 +1,7 @@ defmodule MobilizonWeb.API.Search do + @moduledoc """ + API for Search + """ alias Mobilizon.Service.ActivityPub alias Mobilizon.Actors alias Mobilizon.Actors.Actor @@ -80,7 +83,7 @@ defmodule MobilizonWeb.API.Search do actor else {:error, _err} -> - Logger.debug("Unable to find or make actor '#{search}'") + Logger.debug(fn -> "Unable to find or make actor '#{search}'" end) nil end end @@ -92,7 +95,7 @@ defmodule MobilizonWeb.API.Search do object else {:error, _err} -> - Logger.debug("Unable to find or make object from URL '#{search}'") + Logger.debug(fn -> "Unable to find or make object from URL '#{search}'" end) nil end end diff --git a/priv/repo/migrations/20180109165738_create_accounts.exs b/priv/repo/migrations/20180109165738_create_accounts.exs index c781f03ec..9f67999ea 100644 --- a/priv/repo/migrations/20180109165738_create_accounts.exs +++ b/priv/repo/migrations/20180109165738_create_accounts.exs @@ -3,20 +3,19 @@ defmodule Mobilizon.Repo.Migrations.CreateAccounts do def change do create table(:accounts) do - add :username, :string, null: false - add :domain, :string, null: true - add :display_name, :string, null: true - add :description, :text, null: true - add :private_key, :text, null: true - add :public_key, :text, null: false - add :suspended, :boolean, default: false, null: false - add :uri, :string, null: false - add :url, :string, null: false + add(:username, :string, null: false) + add(:domain, :string, null: true) + add(:display_name, :string, null: true) + add(:description, :text, null: true) + add(:private_key, :text, null: true) + add(:public_key, :text, null: false) + add(:suspended, :boolean, default: false, null: false) + add(:uri, :string, null: false) + add(:url, :string, null: false) timestamps() end - create unique_index(:accounts, [:username, :domain]) - + create(unique_index(:accounts, [:username, :domain])) end end diff --git a/priv/repo/migrations/20180109170315_create_users.exs b/priv/repo/migrations/20180109170315_create_users.exs index b49965b09..76b8146f3 100644 --- a/priv/repo/migrations/20180109170315_create_users.exs +++ b/priv/repo/migrations/20180109170315_create_users.exs @@ -3,14 +3,14 @@ defmodule Mobilizon.Repo.Migrations.CreateUsers do def change do create table(:users) do - add :email, :string, null: false - add :role, :integer, default: 0, null: false - add :password_hash, :string, null: false - add :account_id, references(:accounts, on_delete: :delete_all), null: false + add(:email, :string, null: false) + add(:role, :integer, default: 0, null: false) + add(:password_hash, :string, null: false) + add(:account_id, references(:accounts, on_delete: :delete_all), null: false) timestamps() end - create unique_index(:users, [:email]) + create(unique_index(:users, [:email])) end end diff --git a/priv/repo/migrations/20180110091747_create_categories.exs b/priv/repo/migrations/20180110091747_create_categories.exs index 33a6c6cbb..2680f884e 100644 --- a/priv/repo/migrations/20180110091747_create_categories.exs +++ b/priv/repo/migrations/20180110091747_create_categories.exs @@ -3,14 +3,13 @@ defmodule Mobilizon.Repo.Migrations.CreateCategories do def change do create table(:categories) do - add :title, :string - add :description, :string - add :picture, :string + add(:title, :string) + add(:description, :string) + add(:picture, :string) timestamps() end - create unique_index(:categories, [:title]) - + create(unique_index(:categories, [:title])) end end diff --git a/priv/repo/migrations/20180110092400_create_addresses.exs b/priv/repo/migrations/20180110092400_create_addresses.exs index ad7e96d79..62e5cafda 100644 --- a/priv/repo/migrations/20180110092400_create_addresses.exs +++ b/priv/repo/migrations/20180110092400_create_addresses.exs @@ -3,17 +3,16 @@ defmodule Mobilizon.Repo.Migrations.CreateAddresses do def change do create table(:addresses) do - add :description, :string - add :floor, :string - add :addressCountry, :string - add :addressLocality, :string - add :addressRegion, :string - add :postalCode, :string - add :streetAddress, :string - add :geom, :geometry + add(:description, :string) + add(:floor, :string) + add(:addressCountry, :string) + add(:addressLocality, :string) + add(:addressRegion, :string) + add(:postalCode, :string) + add(:streetAddress, :string) + add(:geom, :geometry) timestamps() end - end end diff --git a/priv/repo/migrations/20180110092500_create_groups.exs b/priv/repo/migrations/20180110092500_create_groups.exs index b03798d0c..635f53174 100644 --- a/priv/repo/migrations/20180110092500_create_groups.exs +++ b/priv/repo/migrations/20180110092500_create_groups.exs @@ -3,18 +3,17 @@ defmodule Mobilizon.Repo.Migrations.CreateGroups do def change do create table(:groups) do - add :title, :string, null: false - add :slug, :string, null: false - add :description, :string - add :suspended, :boolean, default: false, null: false - add :url, :string - add :uri, :string - add :address_id, references(:addresses, on_delete: :delete_all) + add(:title, :string, null: false) + add(:slug, :string, null: false) + add(:description, :string) + add(:suspended, :boolean, default: false, null: false) + add(:url, :string) + add(:uri, :string) + add(:address_id, references(:addresses, on_delete: :delete_all)) timestamps() end - create unique_index(:groups, [:slug]) - + create(unique_index(:groups, [:slug])) end end diff --git a/priv/repo/migrations/20180110092600_create_events.exs b/priv/repo/migrations/20180110092600_create_events.exs index 0a7fb2a3e..5e612f900 100644 --- a/priv/repo/migrations/20180110092600_create_events.exs +++ b/priv/repo/migrations/20180110092600_create_events.exs @@ -3,28 +3,27 @@ defmodule Mobilizon.Repo.Migrations.CreateEvents do def change do create table(:events) do - add :title, :string, null: false - add :slug, :string, null: false - add :description, :string, null: true - add :begins_on, :datetimetz - add :ends_on, :datetimetz - add :state, :integer, null: false - add :public, :boolean, null: false - add :status, :integer, null: false - add :large_image, :string - add :thumbnail, :string - add :publish_at, :datetimetz - add :organizer_account_id, references(:accounts, on_delete: :nothing) - add :organizer_group_id, references(:groups, on_delete: :nothing) - add :category_id, references(:categories, on_delete: :nothing), null: false - add :address_id, references(:addresses, on_delete: :delete_all) + add(:title, :string, null: false) + add(:slug, :string, null: false) + add(:description, :string, null: true) + add(:begins_on, :datetimetz) + add(:ends_on, :datetimetz) + add(:state, :integer, null: false) + add(:public, :boolean, null: false) + add(:status, :integer, null: false) + add(:large_image, :string) + add(:thumbnail, :string) + add(:publish_at, :datetimetz) + add(:organizer_account_id, references(:accounts, on_delete: :nothing)) + add(:organizer_group_id, references(:groups, on_delete: :nothing)) + add(:category_id, references(:categories, on_delete: :nothing), null: false) + add(:address_id, references(:addresses, on_delete: :delete_all)) timestamps() end - create index(:events, [:organizer_account_id]) - create index(:events, [:organizer_group_id]) - create unique_index(:events, [:slug]) - + create(index(:events, [:organizer_account_id])) + create(index(:events, [:organizer_group_id])) + create(unique_index(:events, [:slug])) end end diff --git a/priv/repo/migrations/20180110093905_create_tags.exs b/priv/repo/migrations/20180110093905_create_tags.exs index fafd3c49c..eb4ff6675 100644 --- a/priv/repo/migrations/20180110093905_create_tags.exs +++ b/priv/repo/migrations/20180110093905_create_tags.exs @@ -3,13 +3,12 @@ defmodule Mobilizon.Repo.Migrations.CreateTags do def change do create table(:tags) do - add :title, :string - add :slug, :string, null: false + add(:title, :string) + add(:slug, :string, null: false) timestamps() end - create unique_index(:tags, [:slug]) - + create(unique_index(:tags, [:slug])) end end diff --git a/priv/repo/migrations/20180110093906_create_events_tags.exs b/priv/repo/migrations/20180110093906_create_events_tags.exs index 451d3cd55..b263248e6 100644 --- a/priv/repo/migrations/20180110093906_create_events_tags.exs +++ b/priv/repo/migrations/20180110093906_create_events_tags.exs @@ -3,8 +3,8 @@ defmodule Mobilizon.Repo.Migrations.CreateEventsTags do def change do create table(:events_tags, primary_key: false) do - add :event_id, references(:events) - add :tag_id, references(:tags) + add(:event_id, references(:events)) + add(:tag_id, references(:tags)) end end end diff --git a/priv/repo/migrations/20180110094301_create_participants.exs b/priv/repo/migrations/20180110094301_create_participants.exs index 2b6c724f3..750dacbf5 100644 --- a/priv/repo/migrations/20180110094301_create_participants.exs +++ b/priv/repo/migrations/20180110094301_create_participants.exs @@ -3,15 +3,14 @@ defmodule Mobilizon.Repo.Migrations.CreateParticipants do def change do create table(:participants, primary_key: false) do - add :role, :integer - add :event_id, references(:events, on_delete: :nothing), primary_key: true - add :account_id, references(:accounts, on_delete: :nothing), primary_key: true + add(:role, :integer) + add(:event_id, references(:events, on_delete: :nothing), primary_key: true) + add(:account_id, references(:accounts, on_delete: :nothing), primary_key: true) timestamps() end - create index(:participants, [:event_id]) - create index(:participants, [:account_id]) - + create(index(:participants, [:event_id])) + create(index(:participants, [:account_id])) end end diff --git a/priv/repo/migrations/20180110094502_create_event_requests.exs b/priv/repo/migrations/20180110094502_create_event_requests.exs index 209787826..2a5cf1f62 100644 --- a/priv/repo/migrations/20180110094502_create_event_requests.exs +++ b/priv/repo/migrations/20180110094502_create_event_requests.exs @@ -3,15 +3,14 @@ defmodule Mobilizon.Repo.Migrations.CreateEventRequests do def change do create table(:event_requests) do - add :state, :integer - add :event_id, references(:events, on_delete: :nothing) - add :account_id, references(:accounts, on_delete: :nothing) + add(:state, :integer) + add(:event_id, references(:events, on_delete: :nothing)) + add(:account_id, references(:accounts, on_delete: :nothing)) timestamps() end - create index(:event_requests, [:event_id]) - create index(:event_requests, [:account_id]) - + create(index(:event_requests, [:event_id])) + create(index(:event_requests, [:account_id])) end end diff --git a/priv/repo/migrations/20180110095317_create_members.exs b/priv/repo/migrations/20180110095317_create_members.exs index c079d98c7..c44319bf0 100644 --- a/priv/repo/migrations/20180110095317_create_members.exs +++ b/priv/repo/migrations/20180110095317_create_members.exs @@ -3,15 +3,14 @@ defmodule Mobilizon.Repo.Migrations.CreateMembers do def change do create table(:members, primary_key: false) do - add :role, :integer - add :group_id, references(:groups, on_delete: :nothing) - add :account_id, references(:accounts, on_delete: :nothing) + add(:role, :integer) + add(:group_id, references(:groups, on_delete: :nothing)) + add(:account_id, references(:accounts, on_delete: :nothing)) timestamps() end - create index(:members, [:group_id]) - create index(:members, [:account_id]) - + create(index(:members, [:group_id])) + create(index(:members, [:account_id])) end end diff --git a/priv/repo/migrations/20180110095515_create_group_requests.exs b/priv/repo/migrations/20180110095515_create_group_requests.exs index a6f97c070..9cca7a64e 100644 --- a/priv/repo/migrations/20180110095515_create_group_requests.exs +++ b/priv/repo/migrations/20180110095515_create_group_requests.exs @@ -3,15 +3,14 @@ defmodule Mobilizon.Repo.Migrations.CreateGroupRequests do def change do create table(:group_requests) do - add :state, :integer - add :group_id, references(:groups, on_delete: :nothing) - add :account_id, references(:accounts, on_delete: :nothing) + add(:state, :integer) + add(:group_id, references(:groups, on_delete: :nothing)) + add(:account_id, references(:accounts, on_delete: :nothing)) timestamps() end - create index(:group_requests, [:group_id]) - create index(:group_requests, [:account_id]) - + create(index(:group_requests, [:group_id])) + create(index(:group_requests, [:account_id])) end end diff --git a/priv/repo/migrations/20180112100000_create_tracks.exs b/priv/repo/migrations/20180112100000_create_tracks.exs index a83f6b4b6..f8f5d7645 100644 --- a/priv/repo/migrations/20180112100000_create_tracks.exs +++ b/priv/repo/migrations/20180112100000_create_tracks.exs @@ -3,14 +3,13 @@ defmodule Mobilizon.Repo.Migrations.CreateTracks do def change do create table(:tracks) do - add :name, :string - add :description, :text - add :color, :string + add(:name, :string) + add(:description, :text) + add(:color, :string) - add :event_id, references(:events, on_delete: :delete_all), null: false + add(:event_id, references(:events, on_delete: :delete_all), null: false) timestamps() end - end end diff --git a/priv/repo/migrations/20180112105354_create_sessions.exs b/priv/repo/migrations/20180112105354_create_sessions.exs index f63c90494..f12f82d0c 100644 --- a/priv/repo/migrations/20180112105354_create_sessions.exs +++ b/priv/repo/migrations/20180112105354_create_sessions.exs @@ -3,22 +3,21 @@ defmodule Mobilizon.Repo.Migrations.CreateSessions do def change do create table(:sessions) do - add :title, :string - add :subtitle, :string - add :short_abstract, :text - add :long_abstract, :text - add :language, :string - add :slides_url, :string - add :videos_urls, :string - add :audios_urls, :string - add :begins_on, :datetimetz - add :ends_on, :datetimetz - add :event_id, references(:events, on_delete: :delete_all), null: false - add :track_id, references(:tracks, on_delete: :delete_all) - add :speaker_id, references(:accounts, on_delete: :delete_all) + add(:title, :string) + add(:subtitle, :string) + add(:short_abstract, :text) + add(:long_abstract, :text) + add(:language, :string) + add(:slides_url, :string) + add(:videos_urls, :string) + add(:audios_urls, :string) + add(:begins_on, :datetimetz) + add(:ends_on, :datetimetz) + add(:event_id, references(:events, on_delete: :delete_all), null: false) + add(:track_id, references(:tracks, on_delete: :delete_all)) + add(:speaker_id, references(:accounts, on_delete: :delete_all)) timestamps() end - end end diff --git a/priv/repo/migrations/20180430071244_remove_uri.exs b/priv/repo/migrations/20180430071244_remove_uri.exs index 3c29c71bb..41016a3c0 100644 --- a/priv/repo/migrations/20180430071244_remove_uri.exs +++ b/priv/repo/migrations/20180430071244_remove_uri.exs @@ -3,21 +3,21 @@ defmodule Mobilizon.Repo.Migrations.RemoveUri do def up do alter table("accounts") do - remove :uri + remove(:uri) end alter table("groups") do - remove :uri + remove(:uri) end end def down do alter table("accounts") do - add :uri, :string, null: false, default: "https://" + add(:uri, :string, null: false, default: "https://") end alter table("groups") do - add :uri, :string, null: false, default: "https://" + add(:uri, :string, null: false, default: "https://") end end end diff --git a/priv/repo/migrations/20180515091106_add_url_field_to_events.exs b/priv/repo/migrations/20180515091106_add_url_field_to_events.exs index b2596448b..bfcce8193 100644 --- a/priv/repo/migrations/20180515091106_add_url_field_to_events.exs +++ b/priv/repo/migrations/20180515091106_add_url_field_to_events.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AddUrlFieldToEvents do def up do alter table("events") do - add :url, :string, null: false, default: "https://" + add(:url, :string, null: false, default: "https://") end end def down do alter table("events") do - remove :url + remove(:url) end end end diff --git a/priv/repo/migrations/20180515100237_create_comments.exs b/priv/repo/migrations/20180515100237_create_comments.exs index d93d0069d..48860be05 100644 --- a/priv/repo/migrations/20180515100237_create_comments.exs +++ b/priv/repo/migrations/20180515100237_create_comments.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.CreateComments do def change do create table(:comments) do - add :url, :string - add :text, :text + add(:url, :string) + add(:text, :text) - add :account_id, references(:accounts, on_delete: :nothing), null: false - add :event_id, references(:events, on_delete: :nothing) - add :in_reply_to_comment_id, references(:categories, on_delete: :nothing) - add :origin_comment_id, references(:addresses, on_delete: :delete_all) + add(:account_id, references(:accounts, on_delete: :nothing), null: false) + add(:event_id, references(:events, on_delete: :nothing)) + add(:in_reply_to_comment_id, references(:categories, on_delete: :nothing)) + add(:origin_comment_id, references(:addresses, on_delete: :delete_all)) timestamps() end diff --git a/priv/repo/migrations/20180515142835_alter_event_timestamps_to_date_time_with_time_zone.exs b/priv/repo/migrations/20180515142835_alter_event_timestamps_to_date_time_with_time_zone.exs index ac8f5101b..6885eedbc 100644 --- a/priv/repo/migrations/20180515142835_alter_event_timestamps_to_date_time_with_time_zone.exs +++ b/priv/repo/migrations/20180515142835_alter_event_timestamps_to_date_time_with_time_zone.exs @@ -3,15 +3,15 @@ defmodule Mobilizon.Repo.Migrations.AlterEventTimestampsToDateTimeWithTimeZone d def up do alter table("events") do - modify :inserted_at, :utc_datetime - modify :updated_at, :utc_datetime + modify(:inserted_at, :utc_datetime) + modify(:updated_at, :utc_datetime) end end def down do alter table("events") do - modify :inserted_at, :timestamptz - modify :updated_at, :timestamptz + modify(:inserted_at, :timestamptz) + modify(:updated_at, :timestamptz) end end end diff --git a/priv/repo/migrations/20180515145438_add_local_attribute_to_events_and_comments.exs b/priv/repo/migrations/20180515145438_add_local_attribute_to_events_and_comments.exs index eea70dfe1..e7a39db53 100644 --- a/priv/repo/migrations/20180515145438_add_local_attribute_to_events_and_comments.exs +++ b/priv/repo/migrations/20180515145438_add_local_attribute_to_events_and_comments.exs @@ -3,21 +3,21 @@ defmodule Mobilizon.Repo.Migrations.AddLocalAttributeToEventsAndComments do def up do alter table("events") do - add :local, :boolean, null: false, default: true + add(:local, :boolean, null: false, default: true) end alter table("comments") do - add :local, :boolean, null: false, default: true + add(:local, :boolean, null: false, default: true) end end def down do alter table("events") do - remove :local + remove(:local) end alter table("comments") do - remove :local + remove(:local) end end end diff --git a/priv/repo/migrations/20180517100700_move_from_account_to_actor.exs b/priv/repo/migrations/20180517100700_move_from_account_to_actor.exs index bcbc6ab69..3ba343e97 100644 --- a/priv/repo/migrations/20180517100700_move_from_account_to_actor.exs +++ b/priv/repo/migrations/20180517100700_move_from_account_to_actor.exs @@ -2,101 +2,106 @@ defmodule Mobilizon.Repo.Migrations.MoveFromAccountToActor do use Ecto.Migration def up do - drop table("event_requests") - drop table("group_requests") - + drop(table("event_requests")) + drop(table("group_requests")) alter table("events") do - remove :organizer_group_id + remove(:organizer_group_id) end - rename table("members"), :account_id, to: :actor_id + rename(table("members"), :account_id, to: :actor_id) alter table("members") do - remove :group_id - add :parent_id, references(:accounts, on_delete: :nothing) + remove(:group_id) + add(:parent_id, references(:accounts, on_delete: :nothing)) end - drop table("groups") - rename table("accounts"), to: table("actors") - Mobilizon.Actors.ActorTypeEnum.create_type - rename table("actors"), :username, to: :name - rename table("actors"), :description, to: :summary - rename table("actors"), :display_name, to: :preferred_username + drop(table("groups")) + rename(table("accounts"), to: table("actors")) + Mobilizon.Actors.ActorTypeEnum.create_type() + rename(table("actors"), :username, to: :name) + rename(table("actors"), :description, to: :summary) + rename(table("actors"), :display_name, to: :preferred_username) + alter table("actors") do - add :inbox_url, :string - add :outbox_url, :string - add :following_url, :string, null: true - add :followers_url, :string, null: true - add :shared_inbox_url, :string, null: false, default: "" - add :type, :actor_type - add :manually_approves_followers, :boolean, default: false - modify :name, :string, null: true - modify :preferred_username, :string, null: false + add(:inbox_url, :string) + add(:outbox_url, :string) + add(:following_url, :string, null: true) + add(:followers_url, :string, null: true) + add(:shared_inbox_url, :string, null: false, default: "") + add(:type, :actor_type) + add(:manually_approves_followers, :boolean, default: false) + modify(:name, :string, null: true) + modify(:preferred_username, :string, null: false) end - create unique_index(:actors, [:preferred_username, :domain]) + create(unique_index(:actors, [:preferred_username, :domain])) - rename table("events"), :organizer_account_id, to: :organizer_actor_id + rename(table("events"), :organizer_account_id, to: :organizer_actor_id) - rename table("participants"), :account_id, to: :actor_id + rename(table("participants"), :account_id, to: :actor_id) create table("followers") do - add :approved, :boolean, default: false - add :score, :integer, default: 1000 - add :actor_id, references(:actors, on_delete: :nothing) - add :target_actor_id, references(:actors, on_delete: :nothing) + add(:approved, :boolean, default: false) + add(:score, :integer, default: 1000) + add(:actor_id, references(:actors, on_delete: :nothing)) + add(:target_actor_id, references(:actors, on_delete: :nothing)) end - rename table("comments"), :account_id, to: :actor_id + rename(table("comments"), :account_id, to: :actor_id) - rename table("users"), :account_id, to: :actor_id + rename(table("users"), :account_id, to: :actor_id) end def down do - create table("event_requests") - create table("group_requests") - + create(table("event_requests")) + create(table("group_requests")) alter table("events") do - add :organizer_group_id, :integer + add(:organizer_group_id, :integer) end - rename table("members"), :actor_id, to: :account_id + rename(table("members"), :actor_id, to: :account_id) alter table("members") do - add :group_id, :integer - remove :parent_id + add(:group_id, :integer) + remove(:parent_id) end - create table("groups") - rename table("actors"), to: table("accounts") - rename table("accounts"), :name, to: :username - rename table("accounts"), :summary, to: :description - rename table("accounts"), :preferred_username, to: :display_name + create(table("groups")) + rename(table("actors"), to: table("accounts")) + rename(table("accounts"), :name, to: :username) + rename(table("accounts"), :summary, to: :description) + rename(table("accounts"), :preferred_username, to: :display_name) + alter table("accounts") do - remove :inbox_url - remove :outbox_url - remove :following_url - remove :followers_url - remove :shared_inbox_url - remove :type - remove :manually_approves_followers - modify :username, :string, null: false - modify :display_name, :string, null: true + remove(:inbox_url) + remove(:outbox_url) + remove(:following_url) + remove(:followers_url) + remove(:shared_inbox_url) + remove(:type) + remove(:manually_approves_followers) + modify(:username, :string, null: false) + modify(:display_name, :string, null: true) end + Mobilizon.Actors.ActorTypeEnum.drop_type() - rename table("events"), :organizer_actor_id, to: :organizer_account_id + rename(table("events"), :organizer_actor_id, to: :organizer_account_id) - rename table("participants"), :actor_id, to: :account_id + rename(table("participants"), :actor_id, to: :account_id) - rename table("comments"), :actor_id, to: :account_id + rename(table("comments"), :actor_id, to: :account_id) - rename table("users"), :actor_id, to: :account_id + rename(table("users"), :actor_id, to: :account_id) - drop index("accounts", [:preferred_username, :domain], name: :actors_preferred_username_domain_index) + drop( + index("accounts", [:preferred_username, :domain], + name: :actors_preferred_username_domain_index + ) + ) - drop table("followers") + drop(table("followers")) end end diff --git a/priv/repo/migrations/20180522133844_add_bots_table.exs b/priv/repo/migrations/20180522133844_add_bots_table.exs index 629754a7c..1c3c74500 100644 --- a/priv/repo/migrations/20180522133844_add_bots_table.exs +++ b/priv/repo/migrations/20180522133844_add_bots_table.exs @@ -3,16 +3,16 @@ defmodule Mobilizon.Repo.Migrations.AddBotsTable do def up do create table(:bots) do - add :source, :string, null: false - add :type, :string, default: "ics" - add :actor_id, references(:actors, on_delete: :delete_all), null: false - add :user_id, references(:users, on_delete: :delete_all), null: false + add(:source, :string, null: false) + add(:type, :string, default: "ics") + add(:actor_id, references(:actors, on_delete: :delete_all), null: false) + add(:user_id, references(:users, on_delete: :delete_all), null: false) timestamps() end end def down do - drop table(:bots) + drop(table(:bots)) end end diff --git a/priv/repo/migrations/20180530125159_add_avatar_and_banner_to_actor.exs b/priv/repo/migrations/20180530125159_add_avatar_and_banner_to_actor.exs index e808c1785..2603e7da5 100644 --- a/priv/repo/migrations/20180530125159_add_avatar_and_banner_to_actor.exs +++ b/priv/repo/migrations/20180530125159_add_avatar_and_banner_to_actor.exs @@ -3,15 +3,15 @@ defmodule Mobilizon.Repo.Migrations.AddAvatarAndBannerToActor do def up do alter table(:actors) do - add :avatar_url, :string - add :banner_url, :string + add(:avatar_url, :string) + add(:banner_url, :string) end end def down do alter table(:actors) do - remove :avatar_url - remove :banner_url + remove(:avatar_url) + remove(:banner_url) end end end diff --git a/priv/repo/migrations/20180530152323_make_actor_public_key_nullable.exs b/priv/repo/migrations/20180530152323_make_actor_public_key_nullable.exs index 82ad33be2..4516b4307 100644 --- a/priv/repo/migrations/20180530152323_make_actor_public_key_nullable.exs +++ b/priv/repo/migrations/20180530152323_make_actor_public_key_nullable.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.MakeActorPublicKeyNullable do def up do alter table(:actors) do - modify :public_key, :text, null: true + modify(:public_key, :text, null: true) end end def down do alter table(:actors) do - modify :public_key, :text, null: false + modify(:public_key, :text, null: false) end end end diff --git a/priv/repo/migrations/20180530170808_add_uuid_id_to_events.exs b/priv/repo/migrations/20180530170808_add_uuid_id_to_events.exs index 16e1ee084..090af33c4 100644 --- a/priv/repo/migrations/20180530170808_add_uuid_id_to_events.exs +++ b/priv/repo/migrations/20180530170808_add_uuid_id_to_events.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AddUUIDIdToEvents do def up do alter table(:events) do - add :uuid, :uuid + add(:uuid, :uuid) end end def down do alter table(:events) do - remove :uuid + remove(:uuid) end end end diff --git a/priv/repo/migrations/20180531162301_add_approved_status_to_member.exs b/priv/repo/migrations/20180531162301_add_approved_status_to_member.exs index 241e20599..6e93e3ec6 100644 --- a/priv/repo/migrations/20180531162301_add_approved_status_to_member.exs +++ b/priv/repo/migrations/20180531162301_add_approved_status_to_member.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AddApprovedStatusToMember do def up do alter table(:members) do - add :approved, :boolean, default: true + add(:approved, :boolean, default: true) end end def down do alter table(:members) do - remove :approved + remove(:approved) end end end diff --git a/priv/repo/migrations/20180607095732_add_uuid_to_comments.exs b/priv/repo/migrations/20180607095732_add_uuid_to_comments.exs index 7722f0c2c..f03b70b62 100644 --- a/priv/repo/migrations/20180607095732_add_uuid_to_comments.exs +++ b/priv/repo/migrations/20180607095732_add_uuid_to_comments.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AddUUIDToComments do def up do alter table(:comments) do - add :uuid, :uuid + add(:uuid, :uuid) end end def down do alter table(:comments) do - remove :uuid + remove(:uuid) end end end diff --git a/priv/repo/migrations/20180614094653_make_shared_inbox_url_nullable.exs b/priv/repo/migrations/20180614094653_make_shared_inbox_url_nullable.exs index 44ee0bb5a..a44c29188 100644 --- a/priv/repo/migrations/20180614094653_make_shared_inbox_url_nullable.exs +++ b/priv/repo/migrations/20180614094653_make_shared_inbox_url_nullable.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.MakeSharedInboxUrlNullable do def up do alter table(:actors) do - modify :shared_inbox_url, :string, null: true, default: nil + modify(:shared_inbox_url, :string, null: true, default: nil) end end def down do alter table(:actors) do - add :shared_inbox_url, :string, null: false, default: "" + add(:shared_inbox_url, :string, null: false, default: "") end end end diff --git a/priv/repo/migrations/20180614104618_fusion_public_private_key_into_keys_column.exs b/priv/repo/migrations/20180614104618_fusion_public_private_key_into_keys_column.exs index 0d6d33663..88020136d 100644 --- a/priv/repo/migrations/20180614104618_fusion_public_private_key_into_keys_column.exs +++ b/priv/repo/migrations/20180614104618_fusion_public_private_key_into_keys_column.exs @@ -2,16 +2,17 @@ defmodule Mobilizon.Repo.Migrations.FusionPublicPrivateKeyIntoKeysColumn do use Ecto.Migration def up do - rename table(:actors), :private_key, to: :keys + rename(table(:actors), :private_key, to: :keys) + alter table(:actors) do - remove :public_key + remove(:public_key) end end def down do alter table(:actors) do - rename :keys, to: :private_key - add :public_key, :text, null: true + rename(:keys, to: :private_key) + add(:public_key, :text, null: true) end end end diff --git a/priv/repo/migrations/20180614131328_add_attributed_to_field_to_events_and_comments.exs b/priv/repo/migrations/20180614131328_add_attributed_to_field_to_events_and_comments.exs index c8a9d2015..c768b0eac 100644 --- a/priv/repo/migrations/20180614131328_add_attributed_to_field_to_events_and_comments.exs +++ b/priv/repo/migrations/20180614131328_add_attributed_to_field_to_events_and_comments.exs @@ -3,21 +3,21 @@ defmodule Mobilizon.Repo.Migrations.AddAttributedToFieldToEventsAndComments do def up do alter table(:events) do - add :attributed_to_id, references(:actors, on_delete: :nothing) + add(:attributed_to_id, references(:actors, on_delete: :nothing)) end alter table(:comments) do - add :attributed_to_id, references(:actors, on_delete: :nothing) + add(:attributed_to_id, references(:actors, on_delete: :nothing)) end end def down do alter table(:events) do - remove :attributed_to_id + remove(:attributed_to_id) end alter table(:comments) do - remove :attributed_to_id + remove(:attributed_to_id) end end end diff --git a/priv/repo/migrations/20180628091920_add-user-confirm-email-fields.exs b/priv/repo/migrations/20180628091920_add-user-confirm-email-fields.exs index e30a8b061..02210e6ee 100644 --- a/priv/repo/migrations/20180628091920_add-user-confirm-email-fields.exs +++ b/priv/repo/migrations/20180628091920_add-user-confirm-email-fields.exs @@ -3,18 +3,21 @@ defmodule :"Elixir.Mobilizon.Repo.Migrations.Add-user-confirm-email-fields" do def up do alter table(:users) do - add :confirmed_at, :utc_datetime - add :confirmation_sent_at, :utc_datetime - add :confirmation_token, :string + add(:confirmed_at, :utc_datetime) + add(:confirmation_sent_at, :utc_datetime) + add(:confirmation_token, :string) end - create unique_index(:users, [:confirmation_token], name: "index_unique_users_confirmation_token") + + create( + unique_index(:users, [:confirmation_token], name: "index_unique_users_confirmation_token") + ) end def down do alter table(:users) do - remove :confirmed_at - remove :confirmation_sent_at - remove :confirmation_token + remove(:confirmed_at) + remove(:confirmation_sent_at) + remove(:confirmation_token) end end end diff --git a/priv/repo/migrations/20180628130746_add-user-password-reset-fields.exs b/priv/repo/migrations/20180628130746_add-user-password-reset-fields.exs index 772835221..f2b14749e 100644 --- a/priv/repo/migrations/20180628130746_add-user-password-reset-fields.exs +++ b/priv/repo/migrations/20180628130746_add-user-password-reset-fields.exs @@ -3,16 +3,21 @@ defmodule :"Elixir.Mobilizon.Repo.Migrations.Add-user-password-reset-fields" do def up do alter table(:users) do - add :reset_password_sent_at, :utc_datetime - add :reset_password_token, :string + add(:reset_password_sent_at, :utc_datetime) + add(:reset_password_token, :string) end - create unique_index(:users, [:reset_password_token], name: "index_unique_users_reset_password_token") + + create( + unique_index(:users, [:reset_password_token], + name: "index_unique_users_reset_password_token" + ) + ) end def down do alter table(:users) do - remove :reset_password_sent_at - remove :reset_password_token + remove(:reset_password_sent_at) + remove(:reset_password_token) end end end diff --git a/priv/repo/migrations/20180628142835_revert_alter_event_timestamps.exs b/priv/repo/migrations/20180628142835_revert_alter_event_timestamps.exs index 256ad42c4..16a74052a 100644 --- a/priv/repo/migrations/20180628142835_revert_alter_event_timestamps.exs +++ b/priv/repo/migrations/20180628142835_revert_alter_event_timestamps.exs @@ -3,15 +3,15 @@ defmodule Mobilizon.Repo.Migrations.RevertAlterEventTimestampsToDateTimeWithTime def up do alter table(:events) do - modify :inserted_at, :timestamptz - modify :updated_at, :timestamptz + modify(:inserted_at, :timestamptz) + modify(:updated_at, :timestamptz) end end def down do alter table(:events) do - modify :inserted_at, :utc_datetime - modify :updated_at, :utc_datetime + modify(:inserted_at, :utc_datetime) + modify(:updated_at, :utc_datetime) end end end diff --git a/priv/repo/migrations/20180702150922_add_address_type.exs b/priv/repo/migrations/20180702150922_add_address_type.exs index 253ede470..ac65c3e47 100644 --- a/priv/repo/migrations/20180702150922_add_address_type.exs +++ b/priv/repo/migrations/20180702150922_add_address_type.exs @@ -3,25 +3,29 @@ defmodule Mobilizon.Repo.Migrations.AddAddressType do def up do alter table(:events) do - add :online_address, :string - add :phone, :string + add(:online_address, :string) + add(:phone, :string) end - drop constraint(:events, "events_address_id_fkey") - rename table(:events), :address_id, to: :physical_address_id + + drop(constraint(:events, "events_address_id_fkey")) + rename(table(:events), :address_id, to: :physical_address_id) + alter table(:events) do - modify :physical_address_id, references(:addresses, on_delete: :nothing) + modify(:physical_address_id, references(:addresses, on_delete: :nothing)) end end def down do alter table(:events) do - remove :online_address - remove :phone + remove(:online_address) + remove(:phone) end - drop constraint(:events, "events_physical_address_id_fkey") - rename table(:events), :physical_address_id, to: :address_id + + drop(constraint(:events, "events_physical_address_id_fkey")) + rename(table(:events), :physical_address_id, to: :address_id) + alter table(:events) do - modify :address_id, references(:addresses, on_delete: :nothing) + modify(:address_id, references(:addresses, on_delete: :nothing)) end end end diff --git a/priv/repo/migrations/20180702154630_remove_slug_for_event.exs b/priv/repo/migrations/20180702154630_remove_slug_for_event.exs index 1cc8a018b..69e1a15e8 100644 --- a/priv/repo/migrations/20180702154630_remove_slug_for_event.exs +++ b/priv/repo/migrations/20180702154630_remove_slug_for_event.exs @@ -9,7 +9,7 @@ defmodule Mobilizon.Repo.Migrations.RemoveSlugForEvent do def down do alter table(:events) do - add :slug, :string, null: false + add(:slug, :string, null: false) end end end diff --git a/priv/repo/migrations/20180706082208_alter_events_set_description_as_text.exs b/priv/repo/migrations/20180706082208_alter_events_set_description_as_text.exs index a3d6dc197..c6ac24b20 100644 --- a/priv/repo/migrations/20180706082208_alter_events_set_description_as_text.exs +++ b/priv/repo/migrations/20180706082208_alter_events_set_description_as_text.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AlterEventsSetDescriptionAsText do def up do alter table(:events) do - modify :description, :text + modify(:description, :text) end end def down do alter table(:events) do - modify :description, :string + modify(:description, :string) end end end diff --git a/priv/repo/migrations/20180709154152_allow_multiple_accounts_for_user.exs b/priv/repo/migrations/20180709154152_allow_multiple_accounts_for_user.exs index 0ab8b7415..5d03f89f0 100644 --- a/priv/repo/migrations/20180709154152_allow_multiple_accounts_for_user.exs +++ b/priv/repo/migrations/20180709154152_allow_multiple_accounts_for_user.exs @@ -3,21 +3,21 @@ defmodule Mobilizon.Repo.Migrations.AllowMultipleAccountsForUser do def up do alter table(:actors) do - add :user_id, references(:users, on_delete: :delete_all), null: true + add(:user_id, references(:users, on_delete: :delete_all), null: true) end alter table(:users) do - remove :actor_id + remove(:actor_id) end end def down do alter table(:users) do - add :actor_id, references(:actors, on_delete: :delete_all), null: false + add(:actor_id, references(:actors, on_delete: :delete_all), null: false) end alter table(:actors) do - remove :user_id + remove(:user_id) end end end diff --git a/priv/repo/migrations/20180802133951_make_follower_table_unique.exs b/priv/repo/migrations/20180802133951_make_follower_table_unique.exs index 9b9ffc238..ca81e1825 100644 --- a/priv/repo/migrations/20180802133951_make_follower_table_unique.exs +++ b/priv/repo/migrations/20180802133951_make_follower_table_unique.exs @@ -2,10 +2,18 @@ defmodule Mobilizon.Repo.Migrations.MakeFollowerTableUnique do use Ecto.Migration def up do - create unique_index(:followers, [:actor_id, :target_actor_id], name: :followers_actor_target_actor_unique_index) + create( + unique_index(:followers, [:actor_id, :target_actor_id], + name: :followers_actor_target_actor_unique_index + ) + ) end def down do - drop index(:followers, [:actor_id, :target_actor_id], name: :followers_actor_target_actor_unique_index) + drop( + index(:followers, [:actor_id, :target_actor_id], + name: :followers_actor_target_actor_unique_index + ) + ) end end diff --git a/priv/repo/migrations/20180816093446_add_primary_key_to_member.exs b/priv/repo/migrations/20180816093446_add_primary_key_to_member.exs index eac91b20f..26f2cdac5 100644 --- a/priv/repo/migrations/20180816093446_add_primary_key_to_member.exs +++ b/priv/repo/migrations/20180816093446_add_primary_key_to_member.exs @@ -3,17 +3,22 @@ defmodule Mobilizon.Repo.Migrations.AddPrimaryKeyToMember do def up do execute("ALTER TABLE members DROP CONSTRAINT IF EXISTS members_pkey") - drop_if_exists index(:members, ["members_account_id_index"]) - create unique_index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index) + drop_if_exists(index(:members, ["members_account_id_index"])) + + create( + unique_index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index) + ) + alter table(:members) do - add :id, :serial, primary_key: true + add(:id, :serial, primary_key: true) end end def down do - drop index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index) + drop(index(:members, [:actor_id, :parent_id], name: :members_actor_parent_unique_index)) + alter table(:members) do - remove :id + remove(:id) end end end diff --git a/priv/repo/migrations/20181021161324_add_default_actor_user_field.exs b/priv/repo/migrations/20181021161324_add_default_actor_user_field.exs index 9deb73aea..a127767e6 100644 --- a/priv/repo/migrations/20181021161324_add_default_actor_user_field.exs +++ b/priv/repo/migrations/20181021161324_add_default_actor_user_field.exs @@ -3,13 +3,13 @@ defmodule Mobilizon.Repo.Migrations.AddDefaultActorUserField do def up do alter table(:users) do - add :default_actor_id, :integer + add(:default_actor_id, :integer) end end def down do alter table(:users) do - remove :default_actor_id + remove(:default_actor_id) end end end diff --git a/priv/repo/migrations/20181108165151_fix_comments_references.exs b/priv/repo/migrations/20181108165151_fix_comments_references.exs index 128c2865c..506bd83e3 100644 --- a/priv/repo/migrations/20181108165151_fix_comments_references.exs +++ b/priv/repo/migrations/20181108165151_fix_comments_references.exs @@ -5,22 +5,22 @@ defmodule Mobilizon.Repo.Migrations.FixCommentsReferences do use Ecto.Migration def up do - drop constraint(:comments, "comments_in_reply_to_comment_id_fkey") - drop constraint(:comments, "comments_origin_comment_id_fkey") + drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey")) + drop(constraint(:comments, "comments_origin_comment_id_fkey")) alter table(:comments) do - modify :in_reply_to_comment_id, references(:comments, on_delete: :nothing) - modify :origin_comment_id, references(:comments, on_delete: :nothing) + modify(:in_reply_to_comment_id, references(:comments, on_delete: :nothing)) + modify(:origin_comment_id, references(:comments, on_delete: :nothing)) end end def down do - drop constraint(:comments, "comments_in_reply_to_comment_id_fkey") - drop constraint(:comments, "comments_origin_comment_id_fkey") + drop(constraint(:comments, "comments_in_reply_to_comment_id_fkey")) + drop(constraint(:comments, "comments_origin_comment_id_fkey")) alter table(:comments) do - modify :in_reply_to_comment_id, references(:categories, on_delete: :nothing) - modify :origin_comment_id, references(:addresses, on_delete: :delete_all) + modify(:in_reply_to_comment_id, references(:categories, on_delete: :nothing)) + modify(:origin_comment_id, references(:addresses, on_delete: :delete_all)) end end end diff --git a/priv/repo/migrations/20181203092128_change_actors_indexes.exs b/priv/repo/migrations/20181203092128_change_actors_indexes.exs index 90158e944..1941caedf 100644 --- a/priv/repo/migrations/20181203092128_change_actors_indexes.exs +++ b/priv/repo/migrations/20181203092128_change_actors_indexes.exs @@ -2,18 +2,28 @@ defmodule Mobilizon.Repo.Migrations.ChangeActorsIndexes do use Ecto.Migration def up do - drop index("actors", [:preferred_username, :domain], name: :actors_preferred_username_domain_index) - drop index("actors", [:name, :domain], name: :accounts_username_domain_index) - execute "ALTER INDEX accounts_pkey RENAME TO actors_pkey" - create index("actors", [:preferred_username, :domain, :type], unique: true) - create index("actors", [:url], unique: true) + drop( + index("actors", [:preferred_username, :domain], + name: :actors_preferred_username_domain_index + ) + ) + + drop(index("actors", [:name, :domain], name: :accounts_username_domain_index)) + execute("ALTER INDEX accounts_pkey RENAME TO actors_pkey") + create(index("actors", [:preferred_username, :domain, :type], unique: true)) + create(index("actors", [:url], unique: true)) end def down do - create index("actors", [:preferred_username, :domain], name: :actors_preferred_username_domain_index) - create index("actors", [:name, :domain], name: :accounts_username_domain_index) - execute "ALTER INDEX actors_pkey RENAME TO accounts_pkey" - drop index("actors", [:preferred_username, :domain, :type]) - drop index("actors", [:url]) + create( + index("actors", [:preferred_username, :domain], + name: :actors_preferred_username_domain_index + ) + ) + + create(index("actors", [:name, :domain], name: :accounts_username_domain_index)) + execute("ALTER INDEX actors_pkey RENAME TO accounts_pkey") + drop(index("actors", [:preferred_username, :domain, :type])) + drop(index("actors", [:url])) end end diff --git a/priv/repo/migrations/20190103150805_fix_event_visibility.exs b/priv/repo/migrations/20190103150805_fix_event_visibility.exs index b08dfba06..0d1fd294b 100644 --- a/priv/repo/migrations/20190103150805_fix_event_visibility.exs +++ b/priv/repo/migrations/20190103150805_fix_event_visibility.exs @@ -2,9 +2,10 @@ defmodule Mobilizon.Repo.Migrations.FixEventVisibility do use Ecto.Migration def up do - Mobilizon.Events.EventVisibilityEnum.create_type - Mobilizon.Events.EventStatusEnum.create_type - Mobilizon.Events.CommentVisibilityEnum.create_type + Mobilizon.Events.EventVisibilityEnum.create_type() + Mobilizon.Events.EventStatusEnum.create_type() + Mobilizon.Events.CommentVisibilityEnum.create_type() + alter table(:events) do remove(:public) remove(:status) @@ -26,11 +27,13 @@ defmodule Mobilizon.Repo.Migrations.FixEventVisibility do add(:public, :boolean, null: false, default: false) add(:status, :integer, null: false, default: 0) end + alter table(:comments) do remove(:visibility) end - Mobilizon.Events.EventVisibilityEnum.drop_type - Mobilizon.Events.EventStatusEnum.drop_type - Mobilizon.Events.CommentVisibilityEnum.drop_type + + Mobilizon.Events.EventVisibilityEnum.drop_type() + Mobilizon.Events.EventStatusEnum.drop_type() + Mobilizon.Events.CommentVisibilityEnum.drop_type() end end diff --git a/priv/repo/migrations/20190114162055_remove_address_type.exs b/priv/repo/migrations/20190114162055_remove_address_type.exs index 360f77188..af2679387 100644 --- a/priv/repo/migrations/20190114162055_remove_address_type.exs +++ b/priv/repo/migrations/20190114162055_remove_address_type.exs @@ -3,8 +3,8 @@ defmodule Mobilizon.Repo.Migrations.RemoveAddressType do require Logger def up do - execute "ALTER TABLE \"events\" DROP COLUMN IF EXISTS address_type" - execute "DROP TYPE IF EXISTS address_type" - rename table(:events), :phone, to: :phone_address + execute("ALTER TABLE \"events\" DROP COLUMN IF EXISTS address_type") + execute("DROP TYPE IF EXISTS address_type") + rename(table(:events), :phone, to: :phone_address) end end diff --git a/priv/repo/migrations/20190125143718_group_delete_members_cascade.exs b/priv/repo/migrations/20190125143718_group_delete_members_cascade.exs index ca8a6bc32..c9b75d25f 100644 --- a/priv/repo/migrations/20190125143718_group_delete_members_cascade.exs +++ b/priv/repo/migrations/20190125143718_group_delete_members_cascade.exs @@ -2,12 +2,12 @@ defmodule Mobilizon.Repo.Migrations.GroupDeleteMembersCascade do use Ecto.Migration def change do - drop constraint(:members, "members_account_id_fkey") - drop constraint(:members, "members_parent_id_fkey") + drop(constraint(:members, "members_account_id_fkey")) + drop(constraint(:members, "members_parent_id_fkey")) alter table(:members) do - modify :actor_id, references(:actors, on_delete: :delete_all) - modify :parent_id, references(:actors, on_delete: :delete_all) + modify(:actor_id, references(:actors, on_delete: :delete_all)) + modify(:parent_id, references(:actors, on_delete: :delete_all)) end end end diff --git a/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs b/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs index c1857e3fb..a991ef11b 100644 --- a/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs +++ b/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs @@ -9,17 +9,21 @@ defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do Visibility allowed nullable values previously """ def up do - execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text" - EventVisibilityEnum.drop_type - EventVisibilityEnum.create_type - execute "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type" + execute("ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text") + EventVisibilityEnum.drop_type() + EventVisibilityEnum.create_type() + + execute( + "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type" + ) + + JoinOptionsEnum.create_type() - JoinOptionsEnum.create_type alter table(:events) do add(:join_options, JoinOptionsEnum.type(), null: false, default: "free") end - execute "UPDATE events SET visibility = 'public' WHERE visibility IS NULL" + execute("UPDATE events SET visibility = 'public' WHERE visibility IS NULL") alter table(:events) do modify(:visibility, EventVisibilityEnum.type(), null: false, default: "public") @@ -30,11 +34,15 @@ defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do alter table(:events) do remove(:join_options) end - JoinOptionsEnum.drop_type - execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text" - EventVisibilityEnum.drop_type - EventVisibilityEnum.create_type - execute "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type" + JoinOptionsEnum.drop_type() + + execute("ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text") + EventVisibilityEnum.drop_type() + EventVisibilityEnum.create_type() + + execute( + "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type" + ) end end diff --git a/priv/repo/migrations/20190207134142_move_participant_role_to_enum.exs b/priv/repo/migrations/20190207134142_move_participant_role_to_enum.exs index de371cdf5..68e8a9713 100644 --- a/priv/repo/migrations/20190207134142_move_participant_role_to_enum.exs +++ b/priv/repo/migrations/20190207134142_move_participant_role_to_enum.exs @@ -9,16 +9,17 @@ defmodule Mobilizon.Repo.Migrations.MoveParticipantRoleToEnum do add(:role_tmp, ParticipantRoleEnum.type(), default: "participant") end - execute "UPDATE participants set role_tmp = 'not_approved' where role = 0" - execute "UPDATE participants set role_tmp = 'participant' where role = 1" - execute "UPDATE participants set role_tmp = 'moderator' where role = 2" - execute "UPDATE participants set role_tmp = 'administrator' where role = 3" - execute "UPDATE participants set role_tmp = 'creator' where role = 4" + execute("UPDATE participants set role_tmp = 'not_approved' where role = 0") + execute("UPDATE participants set role_tmp = 'participant' where role = 1") + execute("UPDATE participants set role_tmp = 'moderator' where role = 2") + execute("UPDATE participants set role_tmp = 'administrator' where role = 3") + execute("UPDATE participants set role_tmp = 'creator' where role = 4") alter table(:participants) do remove(:role) end - rename table(:participants), :role_tmp, to: :role + + rename(table(:participants), :role_tmp, to: :role) end def down do @@ -26,17 +27,18 @@ defmodule Mobilizon.Repo.Migrations.MoveParticipantRoleToEnum do add(:role_tmp, :integer, default: 1) end - execute "UPDATE participants set role_tmp = 0 where role = 'not_approved'" - execute "UPDATE participants set role_tmp = 1 where role = 'participant'" - execute "UPDATE participants set role_tmp = 2 where role = 'moderator'" - execute "UPDATE participants set role_tmp = 3 where role = 'administrator'" - execute "UPDATE participants set role_tmp = 4 where role = 'creator'" + execute("UPDATE participants set role_tmp = 0 where role = 'not_approved'") + execute("UPDATE participants set role_tmp = 1 where role = 'participant'") + execute("UPDATE participants set role_tmp = 2 where role = 'moderator'") + execute("UPDATE participants set role_tmp = 3 where role = 'administrator'") + execute("UPDATE participants set role_tmp = 4 where role = 'creator'") alter table(:participants) do remove(:role) end + ParticipantRoleEnum.drop_type() - rename table(:participants), :role_tmp, to: :role + rename(table(:participants), :role_tmp, to: :role) end end diff --git a/priv/repo/migrations/20190208141700_tags_relations.exs b/priv/repo/migrations/20190208141700_tags_relations.exs index e9d745719..1eea7dfd3 100644 --- a/priv/repo/migrations/20190208141700_tags_relations.exs +++ b/priv/repo/migrations/20190208141700_tags_relations.exs @@ -3,20 +3,21 @@ defmodule Mobilizon.Repo.Migrations.TagsRelations do def up do create table(:tag_relations, primary_key: false) do - add :tag_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true - add :link_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true - add :weight, :integer, null: false, default: 1 + add(:tag_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true) + add(:link_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true) + add(:weight, :integer, null: false, default: 1) end - create constraint(:tag_relations, :no_self_loops_check, check: "tag_id <> link_id") - create index(:tag_relations, [:tag_id], name: :index_tag_relations_tag_id) - create index(:tag_relations, [:link_id], name: :index_tag_relations_link_id) + + create(constraint(:tag_relations, :no_self_loops_check, check: "tag_id <> link_id")) + create(index(:tag_relations, [:tag_id], name: :index_tag_relations_tag_id)) + create(index(:tag_relations, [:link_id], name: :index_tag_relations_link_id)) end def down do - drop constraint(:tag_relations, :no_self_loops_check) + drop(constraint(:tag_relations, :no_self_loops_check)) - drop index(:tag_relations, [:tags_id]) - drop index(:tag_relations, [:link_id]) - drop table(:tag_relations) + drop(index(:tag_relations, [:tags_id])) + drop(index(:tag_relations, [:link_id])) + drop(table(:tag_relations)) end end diff --git a/priv/repo/migrations/20190214100858_drop_datetimetz.exs b/priv/repo/migrations/20190214100858_drop_datetimetz.exs index 8515375bd..721318bbf 100644 --- a/priv/repo/migrations/20190214100858_drop_datetimetz.exs +++ b/priv/repo/migrations/20190214100858_drop_datetimetz.exs @@ -18,7 +18,7 @@ defmodule Mobilizon.Repo.Migrations.DropDatetimetz do add(:ends_on, :utc_datetime) end - execute "DROP TYPE datetimetz" + execute("DROP TYPE datetimetz") end def down do diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 62d3f430f..f3367609b 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -39,4 +39,3 @@ insert(:participant, actor: actor, event: event4, role: :participant) # Insert a group group = insert(:actor, type: :Group) -