mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-06-10 09:19:34 +00:00
Experimenting with CockroachDB
This commit is contained in:
parent
52a3f0f08b
commit
137cb8d96c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Pleroma.Repo.Migrations.MakeFollowingPostgresArray do
|
||||
use Ecto.Migration
|
||||
@disable_ddl_transaction true
|
||||
|
||||
def up do
|
||||
alter table(:users) do
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue