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 d8131c21c0
commit f01819e663

View File

@ -5,6 +5,8 @@ defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do
@doc """ @doc """
EventVisibilityEnum has dropped some possible values, so we need to recreate it EventVisibilityEnum has dropped some possible values, so we need to recreate it
Visibility allowed nullable values previously
""" """
def up do def up do
execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text" 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 alter table(:events) do
add(:join_options, JoinOptionsEnum.type(), null: false, default: "free") add(:join_options, JoinOptionsEnum.type(), null: false, default: "free")
end 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 end
def down do def down do