From d4b20c96c4030ebb5eb908dc6efcf45be7a8355d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 28 May 2020 15:34:11 -0500 Subject: Migrate old notification settings to new variants --- ...28160439_users_update_notification_settings.exs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 priv/repo/migrations/20200528160439_users_update_notification_settings.exs (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200528160439_users_update_notification_settings.exs b/priv/repo/migrations/20200528160439_users_update_notification_settings.exs new file mode 100644 index 000000000..561f7a2c4 --- /dev/null +++ b/priv/repo/migrations/20200528160439_users_update_notification_settings.exs @@ -0,0 +1,43 @@ +defmodule Pleroma.Repo.Migrations.UsersUpdateNotificationSettings do + use Ecto.Migration + + def up do + execute( + "UPDATE users SET notification_settings = notification_settings - 'followers' || jsonb_build_object('from_followers', notification_settings->'followers') +where notification_settings ? 'followers' +and local" + ) + + execute( + "UPDATE users SET notification_settings = notification_settings - 'follows' || jsonb_build_object('from_following', notification_settings->'follows') +where notification_settings ? 'follows' +and local" + ) + + execute( + "UPDATE users SET notification_settings = notification_settings - 'non_followers' || jsonb_build_object('from_strangers', notification_settings->'non_followers') +where notification_settings ? 'non_followers' +and local" + ) + end + + def down do + execute( + "UPDATE users SET notification_settings = notification_settings - 'from_followers' || jsonb_build_object('followers', notification_settings->'from_followers') +where notification_settings ? 'from_followers' +and local" + ) + + execute( + "UPDATE users SET notification_settings = notification_settings - 'from_following' || jsonb_build_object('follows', notification_settings->'from_following') +where notification_settings ? 'from_following' +and local" + ) + + execute( + "UPDATE users SET notification_settings = notification_settings - 'from_strangers' || jsonb_build_object('non_follows', notification_settings->'from_strangers') +where notification_settings ? 'from_strangers' +and local" + ) + end +end -- cgit v1.2.3 From fd5e797379155e5a85deb88dc79f8fbca483948e Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 26 Jun 2020 11:24:28 -0500 Subject: Simplify notification filtering settings further --- ...28160439_users_update_notification_settings.exs | 43 ---------------------- 1 file changed, 43 deletions(-) delete mode 100644 priv/repo/migrations/20200528160439_users_update_notification_settings.exs (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200528160439_users_update_notification_settings.exs b/priv/repo/migrations/20200528160439_users_update_notification_settings.exs deleted file mode 100644 index 561f7a2c4..000000000 --- a/priv/repo/migrations/20200528160439_users_update_notification_settings.exs +++ /dev/null @@ -1,43 +0,0 @@ -defmodule Pleroma.Repo.Migrations.UsersUpdateNotificationSettings do - use Ecto.Migration - - def up do - execute( - "UPDATE users SET notification_settings = notification_settings - 'followers' || jsonb_build_object('from_followers', notification_settings->'followers') -where notification_settings ? 'followers' -and local" - ) - - execute( - "UPDATE users SET notification_settings = notification_settings - 'follows' || jsonb_build_object('from_following', notification_settings->'follows') -where notification_settings ? 'follows' -and local" - ) - - execute( - "UPDATE users SET notification_settings = notification_settings - 'non_followers' || jsonb_build_object('from_strangers', notification_settings->'non_followers') -where notification_settings ? 'non_followers' -and local" - ) - end - - def down do - execute( - "UPDATE users SET notification_settings = notification_settings - 'from_followers' || jsonb_build_object('followers', notification_settings->'from_followers') -where notification_settings ? 'from_followers' -and local" - ) - - execute( - "UPDATE users SET notification_settings = notification_settings - 'from_following' || jsonb_build_object('follows', notification_settings->'from_following') -where notification_settings ? 'from_following' -and local" - ) - - execute( - "UPDATE users SET notification_settings = notification_settings - 'from_strangers' || jsonb_build_object('non_follows', notification_settings->'from_strangers') -where notification_settings ? 'from_strangers' -and local" - ) - end -end -- cgit v1.2.3 From 69848d5c97c9e5d4c14fb5613eb174cb81d5026d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 26 Jun 2020 12:45:46 -0500 Subject: Rename notification "privacy_option" setting --- ...00626163359_rename_notification_privacy_option.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 priv/repo/migrations/20200626163359_rename_notification_privacy_option.exs (limited to 'priv/repo') diff --git a/priv/repo/migrations/20200626163359_rename_notification_privacy_option.exs b/priv/repo/migrations/20200626163359_rename_notification_privacy_option.exs new file mode 100644 index 000000000..06d7f7272 --- /dev/null +++ b/priv/repo/migrations/20200626163359_rename_notification_privacy_option.exs @@ -0,0 +1,19 @@ +defmodule Pleroma.Repo.Migrations.RenameNotificationPrivacyOption do + use Ecto.Migration + + def up do + execute( + "UPDATE users SET notification_settings = notification_settings - 'privacy_option' || jsonb_build_object('hide_notification_contents', notification_settings->'privacy_option') +where notification_settings ? 'privacy_option' +and local" + ) + end + + def down do + execute( + "UPDATE users SET notification_settings = notification_settings - 'hide_notification_contents' || jsonb_build_object('privacy_option', notification_settings->'hide_notification_contents') +where notification_settings ? 'hide_notification_contents' +and local" + ) + end +end -- cgit v1.2.3