Set visibility field default to null

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-02-07 14:01:38 +01:00
parent a2070b1d54
commit 1b3ee17d72
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -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