Added Hashtag entity and objects-hashtags association with auto-sync with data.tag on Object update.
This commit is contained in:
parent
ee221277b0
commit
e369b1306b
6 changed files with 143 additions and 9 deletions
14
priv/repo/migrations/20201221202251_create_hashtags.exs
Normal file
14
priv/repo/migrations/20201221202251_create_hashtags.exs
Normal 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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue