From f01819e6637399d4b132aa8591e055c66d43dac6 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 7 Feb 2019 14:01:38 +0100 Subject: [PATCH] Set visibility field default to null Signed-off-by: Thomas Citharel --- ...0130151607_split_event_visibility_and_join_options.exs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs b/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs index de1486660..c1857e3fb 100644 --- a/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs +++ b/priv/repo/migrations/20190130151607_split_event_visibility_and_join_options.exs @@ -5,6 +5,8 @@ defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do @doc """ EventVisibilityEnum has dropped some possible values, so we need to recreate it + + Visibility allowed nullable values previously """ def up do execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text" @@ -16,6 +18,12 @@ defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do alter table(:events) do add(:join_options, JoinOptionsEnum.type(), null: false, default: "free") end + + execute "UPDATE events SET visibility = 'public' WHERE visibility IS NULL" + + alter table(:events) do + modify(:visibility, EventVisibilityEnum.type(), null: false, default: "public") + end end def down do