Added Hashtag entity and objects-hashtags association with auto-sync with data.tag on Object update.

This commit is contained in:
Ivan Tashkinov 2020-12-22 22:04:33 +03:00
commit e369b1306b
6 changed files with 143 additions and 9 deletions

View file

@ -0,0 +1,14 @@
defmodule Pleroma.Repo.Migrations.CreateHashtags do
use Ecto.Migration
def change do
create_if_not_exists table(:hashtags) do
add(:name, :citext, null: false)
add(:data, :map, default: %{})
timestamps()
end
create_if_not_exists(unique_index(:hashtags, [:name]))
end
end

View file

@ -0,0 +1,13 @@
defmodule Pleroma.Repo.Migrations.CreateHashtagsObjects do
use Ecto.Migration
def change do
create_if_not_exists table(:hashtags_objects) do
add(:hashtag_id, references(:hashtags), null: false)
add(:object_id, references(:objects), null: false)
end
create_if_not_exists(unique_index(:hashtags_objects, [:hashtag_id, :object_id]))
create_if_not_exists(index(:hashtags_objects, [:object_id]))
end
end