Make Categories a predefined list

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Allow null values for categories for now

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-02-22 16:54:01 +01:00
parent 75554cd3f5
commit 7086fe8389
27 changed files with 89 additions and 655 deletions

View File

@@ -0,0 +1,35 @@
defmodule Mobilizon.Repo.Migrations.DropCategories do
use Ecto.Migration
def up do
# The category field is a string for the time being
# while we determine the definitive minimal list of
# categories in https://framagit.org/framasoft/mobilizon/issues/30
# afterwards it will be a PostgreSQL enum and we'll
# just add new elements without being able to delete
# the previous ones
alter table(:events) do
add(:category, :string)
remove(:category_id)
end
drop(table(:categories))
end
def down do
create table(:categories) do
add(:title, :string)
add(:description, :string)
add(:picture, :string)
timestamps()
end
create(unique_index(:categories, [:title]))
alter table(:events) do
remove(:category)
add(:category_id, references(:categories, on_delete: :nothing))
end
end
end