diff options
Diffstat (limited to 'priv/repo/migrations')
8 files changed, 100 insertions, 0 deletions
diff --git a/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs b/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs new file mode 100644 index 000000000..2d9be3aab --- /dev/null +++ b/priv/repo/migrations/20171019141706_create_password_reset_tokens.exs @@ -0,0 +1,13 @@ +defmodule Pleroma.Repo.Migrations.CreatePasswordResetTokens do + use Ecto.Migration + + def change do + create table(:password_reset_tokens) do + add :token, :string + add :user_id, references(:users) + add :used, :boolean, default: false + + timestamps() + end + end +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 new file mode 100644 index 000000000..c6df53ec9 --- /dev/null +++ b/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs @@ -0,0 +1,10 @@ +defmodule Pleroma.Repo.Migrations.AddSecondObjectIndexToActivty do + use Ecto.Migration + + @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) + end +end diff --git a/priv/repo/migrations/20171024090137_drop_object_index.exs b/priv/repo/migrations/20171024090137_drop_object_index.exs new file mode 100644 index 000000000..29b4c9333 --- /dev/null +++ b/priv/repo/migrations/20171024090137_drop_object_index.exs @@ -0,0 +1,7 @@ +defmodule Pleroma.Repo.Migrations.DropObjectIndex do + use Ecto.Migration + + def change do + 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 new file mode 100644 index 000000000..344c9c825 --- /dev/null +++ b/priv/repo/migrations/20171024121413_add_object_actor_index.exs @@ -0,0 +1,9 @@ +defmodule Pleroma.Repo.Migrations.AddObjectActorIndex do + use Ecto.Migration + + @disable_ddl_transaction true + + def change do + 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 new file mode 100644 index 000000000..2d8b60a91 --- /dev/null +++ b/priv/repo/migrations/20171109091239_add_actor_to_activity.exs @@ -0,0 +1,20 @@ +defmodule Pleroma.Repo.Migrations.AddActorToActivity do + use Ecto.Migration + + @disable_ddl_transaction true + + def up do + alter table(:activities) do + add :actor, :string + end + + create index(:activities, [:actor, "id DESC NULLS LAST"], concurrently: true) + end + + def down do + drop index(:activities, [:actor, "id DESC NULLS LAST"]) + alter table(:activities) do + 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 new file mode 100644 index 000000000..255ca46d5 --- /dev/null +++ b/priv/repo/migrations/20171109114020_fill_actor_field.exs @@ -0,0 +1,26 @@ +defmodule Pleroma.Repo.Migrations.FillActorField do + use Ecto.Migration + + alias Pleroma.{Repo, Activity} + + def up do + max = Repo.aggregate(Activity, :max, :id) + if max do + IO.puts("#{max} activities") + chunks = 0..(round(max / 10_000)) + + 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 + end) + end + end + + 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 new file mode 100644 index 000000000..2d21c56ca --- /dev/null +++ b/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs @@ -0,0 +1,8 @@ +defmodule Pleroma.Repo.Migrations.AddSortIndexToActivities do + use Ecto.Migration + @disable_ddl_transaction true + + def change do + 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 new file mode 100644 index 000000000..25716be21 --- /dev/null +++ b/priv/repo/migrations/20171130135819_add_local_index_to_user.exs @@ -0,0 +1,7 @@ +defmodule Pleroma.Repo.Migrations.AddLocalIndexToUser do + use Ecto.Migration + + def change do + create index(:users, [:local]) + end +end |