summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-12-22 22:04:33 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-12-22 22:04:33 +0300
commite369b1306b2f8b9732c21333b9957f7e4e408f90 (patch)
tree78b7a949f3af1ca1313bb58404646b11f7043473 /priv
parentee221277b05d2f682c340c1e1b81fbce4931735a (diff)
downloadpleroma-e369b1306b2f8b9732c21333b9957f7e4e408f90.tar.gz
pleroma-e369b1306b2f8b9732c21333b9957f7e4e408f90.zip
Added Hashtag entity and objects-hashtags association with auto-sync with `data.tag` on Object update.
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20201221202251_create_hashtags.exs14
-rw-r--r--priv/repo/migrations/20201221203824_create_hashtags_objects.exs13
2 files changed, 27 insertions, 0 deletions
diff --git a/priv/repo/migrations/20201221202251_create_hashtags.exs b/priv/repo/migrations/20201221202251_create_hashtags.exs
new file mode 100644
index 000000000..afc522002
--- /dev/null
+++ b/priv/repo/migrations/20201221202251_create_hashtags.exs
@@ -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
diff --git a/priv/repo/migrations/20201221203824_create_hashtags_objects.exs b/priv/repo/migrations/20201221203824_create_hashtags_objects.exs
new file mode 100644
index 000000000..b2649b4fb
--- /dev/null
+++ b/priv/repo/migrations/20201221203824_create_hashtags_objects.exs
@@ -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