[#3213] Explicitly defined PKs in hashtags_objects and data_migration_failed_ids. Added "pleroma.database rollback" task to revert a single migration.

This commit is contained in:
Ivan Tashkinov 2021-01-31 22:03:59 +03:00
commit 108e90b18e
4 changed files with 31 additions and 5 deletions

View file

@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.CreateHashtagsObjects do
def change do
create_if_not_exists table(:hashtags_objects, primary_key: false) do
add(:hashtag_id, references(:hashtags), null: false)
add(:object_id, references(:objects), null: false)
add(:hashtag_id, references(:hashtags), null: false, primary_key: true)
add(:object_id, references(:objects), null: false, primary_key: true)
end
create_if_not_exists(unique_index(:hashtags_objects, [:hashtag_id, :object_id]))

View file

@ -10,5 +10,7 @@ defmodule Pleroma.Repo.Migrations.DataMigrationCreatePopulateHashtagsTable do
)
end
def down, do: :ok
def down do
execute("DELETE FROM data_migrations WHERE name = 'populate_hashtags_table';")
end
end

View file

@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.CreateDataMigrationFailedIds do
def change do
create_if_not_exists table(:data_migration_failed_ids, primary_key: false) do
add(:data_migration_id, references(:data_migrations), null: false)
add(:record_id, :bigint, null: false)
add(:data_migration_id, references(:data_migrations), null: false, primary_key: true)
add(:record_id, :bigint, null: false, primary_key: true)
end
create_if_not_exists(