From 137cb8d96c7e5aaa95e94748af3d0bd82044d3f6 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Dec 2021 11:23:12 -0600 Subject: [PATCH] Experimenting with CockroachDB --- .../20170427054757_add_user_and_hub.exs | 2 +- .../20170522160642_case_insensivtivity.exs | 18 +++++++------ ...0916090107_add_fts_index_to_activities.exs | 16 ++++++------ ...212163643_add_recipients_to_activities.exs | 2 +- ...21210540_make_following_postgres_array.exs | 1 + .../20180516144508_add_trigram_extension.exs | 25 +++++++++++-------- ...180516154905_create_user_trigram_index.exs | 7 +++--- .../20180530123448_add_list_follow_index.exs | 3 ++- ...ipients_to_and_cc_fields_to_activities.exs | 4 +-- ...ients_to_and_cc_fields_from_activities.exs | 4 +-- .../20181201104428_add_uuid_extension.exs | 3 ++- .../20181206125616_add_tags_to_users.exs | 2 +- ...18172826_users_and_activities_flake_id.exs | 4 +-- .../20201221202251_create_hashtags.exs | 2 +- ...222184616_change_hashtags_name_to_text.exs | 2 +- 15 files changed, 53 insertions(+), 42 deletions(-) diff --git a/priv/repo/migrations/20170427054757_add_user_and_hub.exs b/priv/repo/migrations/20170427054757_add_user_and_hub.exs index f33a8572f..1678cf001 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) end end end diff --git a/priv/repo/migrations/20170522160642_case_insensivtivity.exs b/priv/repo/migrations/20170522160642_case_insensivtivity.exs index 9a67727e9..eb72966e5 100644 --- a/priv/repo/migrations/20170522160642_case_insensivtivity.exs +++ b/priv/repo/migrations/20170522160642_case_insensivtivity.exs @@ -6,15 +6,17 @@ defmodule Pleroma.Repo.Migrations.CaseInsensivtivity do # inconsistent failures happen because of index on `email` column. def up do - execute("create extension if not exists citext") + # execute("create extension if not exists citext") + # + # alter table(:users) do + # modify(:email, :citext) + # end + # + # alter table(:users) do + # modify(:nickname, :citext) + # end - alter table(:users) do - modify(:email, :citext) - end - - alter table(:users) do - modify(:nickname, :citext) - end + :ok end def down do 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 717e25412..ef171539f 100644 --- a/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs +++ b/priv/repo/migrations/20170916090107_add_fts_index_to_activities.exs @@ -3,12 +3,14 @@ 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 + # ) + # ) + + :ok 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 6344fbeee..31ddb6bce 100644 --- a/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs +++ b/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs @@ -6,6 +6,6 @@ defmodule Pleroma.Repo.Migrations.AddRecipientsToActivities do 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/20180221210540_make_following_postgres_array.exs b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs index 34e94fdc8..371ebd511 100644 --- a/priv/repo/migrations/20180221210540_make_following_postgres_array.exs +++ b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs @@ -1,5 +1,6 @@ defmodule Pleroma.Repo.Migrations.MakeFollowingPostgresArray do use Ecto.Migration + @disable_ddl_transaction true def up do alter table(:users) do diff --git a/priv/repo/migrations/20180516144508_add_trigram_extension.exs b/priv/repo/migrations/20180516144508_add_trigram_extension.exs index ff0710f84..8ef6e340d 100644 --- a/priv/repo/migrations/20180516144508_add_trigram_extension.exs +++ b/priv/repo/migrations/20180516144508_add_trigram_extension.exs @@ -3,20 +3,23 @@ defmodule Pleroma.Repo.Migrations.AddTrigramExtension do require Logger def up do - Logger.warn("ATTENTION ATTENTION ATTENTION\n") + # 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" + # ) + # + # execute("create extension if not exists pg_trgm") - 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") + :ok end def down do - execute("drop extension if exists pg_trgm") + # execute("drop extension if exists pg_trgm") + :ok end end diff --git a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs index 0713a7297..72d4622ef 100644 --- a/priv/repo/migrations/20180516154905_create_user_trigram_index.exs +++ b/priv/repo/migrations/20180516154905_create_user_trigram_index.exs @@ -2,8 +2,9 @@ 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) + # ) + :ok 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 57f8d478f..c08950aa7 100644 --- a/priv/repo/migrations/20180530123448_add_list_follow_index.exs +++ b/priv/repo/migrations/20180530123448_add_list_follow_index.exs @@ -2,6 +2,7 @@ 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])) + :ok 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 481986039..95cafb01f 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 @@ -7,7 +7,7 @@ defmodule Pleroma.Repo.Migrations.AddRecipientsToAndCcFieldsToActivities do 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/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 65576b8d5..8a6c67ee9 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,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.RemoveRecipientsToAndCcFieldsFromActivities do def up do alter table(:activities) do - remove(:recipients_to) - remove(:recipients_cc) + remove_if_exists(:recipients_to, {:array, :string}) + remove_if_exists(:recipients_cc, {:array, :string}) end end diff --git a/priv/repo/migrations/20181201104428_add_uuid_extension.exs b/priv/repo/migrations/20181201104428_add_uuid_extension.exs index 99fcb957c..b4c53d805 100644 --- a/priv/repo/migrations/20181201104428_add_uuid_extension.exs +++ b/priv/repo/migrations/20181201104428_add_uuid_extension.exs @@ -2,7 +2,8 @@ defmodule Pleroma.Repo.Migrations.AddUUIDExtension do use Ecto.Migration def up do - execute("create extension if not exists \"uuid-ossp\"") + # execute("create extension if not exists \"uuid-ossp\"") + :ok end def down, do: :ok diff --git a/priv/repo/migrations/20181206125616_add_tags_to_users.exs b/priv/repo/migrations/20181206125616_add_tags_to_users.exs index a46c0fc35..c7b6105dd 100644 --- a/priv/repo/migrations/20181206125616_add_tags_to_users.exs +++ b/priv/repo/migrations/20181206125616_add_tags_to_users.exs @@ -6,6 +6,6 @@ defmodule Pleroma.Repo.Migrations.AddTagsToUsers do 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/20181218172826_users_and_activities_flake_id.exs b/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs index c58d829af..b7e0ebafc 100644 --- a/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs +++ b/priv/repo/migrations/20181218172826_users_and_activities_flake_id.exs @@ -22,8 +22,8 @@ defmodule Pleroma.Repo.Migrations.UsersAndActivitiesFlakeId do 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(""" ALTER TABLE activities diff --git a/priv/repo/migrations/20201221202251_create_hashtags.exs b/priv/repo/migrations/20201221202251_create_hashtags.exs index 8d2e9ae66..d285f2524 100644 --- a/priv/repo/migrations/20201221202251_create_hashtags.exs +++ b/priv/repo/migrations/20201221202251_create_hashtags.exs @@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.CreateHashtags do def change do create_if_not_exists table(:hashtags) do - add(:name, :citext, null: false) + add(:name, :text, null: false) timestamps() end diff --git a/priv/repo/migrations/20210222184616_change_hashtags_name_to_text.exs b/priv/repo/migrations/20210222184616_change_hashtags_name_to_text.exs index 8940b6ca3..268e0d2ac 100644 --- a/priv/repo/migrations/20210222184616_change_hashtags_name_to_text.exs +++ b/priv/repo/migrations/20210222184616_change_hashtags_name_to_text.exs @@ -9,7 +9,7 @@ defmodule Pleroma.Repo.Migrations.ChangeHashtagsNameToText do def down do alter table(:hashtags) do - modify(:name, :citext) + modify(:name, :text) end end end