aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-11-01 13:31:55 +0100
committerlain <lain@soykaf.club>2019-11-01 13:31:55 +0100
commit8ad75f9ecf16641699248ac83acc9f4d0edeba88 (patch)
tree96155340ebbca94a09a4ef5c0f7e2409b0af563c
parenta43b899e94c499a9b5cb1a072fe4b96f0f02696f (diff)
downloadpleroma-8ad75f9ecf16641699248ac83acc9f4d0edeba88.tar.gz
Migrations: Add migration to fill empty info fields and make them non-null.
-rw-r--r--priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs17
1 files changed, 17 insertions, 0 deletions
diff --git a/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs b/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs
new file mode 100644
index 000000000..9602a8c41
--- /dev/null
+++ b/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs
@@ -0,0 +1,17 @@
+defmodule Pleroma.Repo.Migrations.FixAndSecureUserInfoField do
+ use Ecto.Migration
+
+ def up do
+ execute("UPDATE users SET info = '{}'::jsonb WHERE info IS NULL")
+
+ execute("ALTER TABLE users
+ ALTER COLUMN info SET NOT NULL
+ ")
+ end
+
+ def down do
+ execute("ALTER TABLE users
+ ALTER COLUMN info DROP NOT NULL
+ ")
+ end
+end