aboutsummaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2020-10-14 09:29:23 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2021-03-20 08:36:28 +0300
commit34d8ce945f88085c9c199b830eccac3fe3727f56 (patch)
tree6eb9c6e9193e23f290dd890b3b74b1e61f85b59b /priv
parent35e85734838e5318a8ca2c48fb0e67750621941b (diff)
downloadpleroma-34d8ce945f88085c9c199b830eccac3fe3727f56.tar.gz
added `Tag` schema
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20201012093959_create_tags.exs27
1 files changed, 27 insertions, 0 deletions
diff --git a/priv/repo/migrations/20201012093959_create_tags.exs b/priv/repo/migrations/20201012093959_create_tags.exs
new file mode 100644
index 000000000..54bf8a2ce
--- /dev/null
+++ b/priv/repo/migrations/20201012093959_create_tags.exs
@@ -0,0 +1,27 @@
+defmodule Pleroma.Repo.Migrations.CreateTags do
+ use Ecto.Migration
+
+ def up do
+ create_if_not_exists table(:tags) do
+ add(:name, :string, null: false)
+ timestamps()
+ end
+
+ create_if_not_exists(unique_index(:tags, :name))
+ flush()
+
+ execute(collect_user_tags_query())
+ end
+
+ def down do
+ drop_if_exists(table(:tags))
+ end
+
+ defp collect_user_tags_query do
+ """
+ INSERT INTO tags(name, inserted_at, updated_at)
+ SELECT DISTINCT unnest(tags), now(), now() from users
+ ON CONFLICT DO NOTHING
+ """
+ end
+end