From 8ad75f9ecf16641699248ac83acc9f4d0edeba88 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 1 Nov 2019 13:31:55 +0100 Subject: [PATCH] Migrations: Add migration to fill empty info fields and make them non-null. --- ...711042020_fix_and_secure_user_info_field.exs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs 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 -- 2.45.2