@@ -4,7 +4,7 @@ defmodule Mobilizon.Repo.Migrations.FixEventVisibility do
|
||||
def up do
|
||||
Mobilizon.Events.EventVisibility.create_type()
|
||||
Mobilizon.Events.EventStatus.create_type()
|
||||
Mobilizon.Conversations.CommentVisibility.create_type()
|
||||
Mobilizon.Discussions.CommentVisibility.create_type()
|
||||
|
||||
alter table(:events) do
|
||||
remove(:public)
|
||||
@@ -15,7 +15,7 @@ defmodule Mobilizon.Repo.Migrations.FixEventVisibility do
|
||||
end
|
||||
|
||||
alter table(:comments) do
|
||||
add(:visibility, Mobilizon.Conversations.CommentVisibility.type())
|
||||
add(:visibility, Mobilizon.Discussions.CommentVisibility.type())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,6 +34,6 @@ defmodule Mobilizon.Repo.Migrations.FixEventVisibility do
|
||||
|
||||
Mobilizon.Events.EventVisibility.drop_type()
|
||||
Mobilizon.Events.EventStatus.drop_type()
|
||||
Mobilizon.Conversations.CommentVisibility.drop_type()
|
||||
Mobilizon.Discussions.CommentVisibility.drop_type()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ defmodule Mobilizon.Storage.Repo.Migrations.RenamePostgresTypes do
|
||||
use Ecto.Migration
|
||||
alias Mobilizon.Actors.{ActorVisibility, MemberRole}
|
||||
|
||||
alias Mobilizon.Conversations.CommentVisibility
|
||||
alias Mobilizon.Discussions.CommentVisibility
|
||||
|
||||
alias Mobilizon.Events.{
|
||||
JoinOptions,
|
||||
|
||||
47
priv/repo/migrations/20200708080516_create_posts.exs
Normal file
47
priv/repo/migrations/20200708080516_create_posts.exs
Normal file
@@ -0,0 +1,47 @@
|
||||
defmodule Mobilizon.Repo.Migrations.CreatePosts do
|
||||
use Ecto.Migration
|
||||
|
||||
alias Mobilizon.Posts.PostVisibility
|
||||
|
||||
def up do
|
||||
PostVisibility.create_type()
|
||||
|
||||
create table(:posts, primary_key: false) do
|
||||
add(:id, :uuid, primary_key: true)
|
||||
add(:title, :string)
|
||||
add(:slug, :string)
|
||||
add(:url, :string)
|
||||
add(:body, :text)
|
||||
add(:draft, :boolean, default: false, null: false)
|
||||
add(:local, :boolean, default: true, null: false)
|
||||
add(:visibility, PostVisibility.type(), default: "public")
|
||||
add(:publish_at, :utc_datetime)
|
||||
add(:author_id, references(:actors, on_delete: :delete_all))
|
||||
add(:attributed_to_id, references(:actors, on_delete: :delete_all))
|
||||
add(:picture_id, references(:pictures, on_delete: :delete_all))
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create table(:posts_tags, primary_key: false) do
|
||||
add(:post_id, references(:posts, on_delete: :delete_all, type: :uuid), primary_key: true)
|
||||
add(:tag_id, references(:tags, on_delete: :delete_all), primary_key: true)
|
||||
end
|
||||
|
||||
alter table(:actors) do
|
||||
add(:posts_url, :string, null: true)
|
||||
add(:events_url, :string, null: true)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
drop(table(:posts_tags))
|
||||
drop(table(:posts))
|
||||
PostVisibility.drop_type()
|
||||
|
||||
alter table(:actors) do
|
||||
remove(:posts_url, :string, null: true)
|
||||
remove(:events_url, :string, null: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
defmodule Mobilizon.Storage.Repo.Migrations.RenameConversationsToDiscussions do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
rename(table("conversations"), to: table("discussions"))
|
||||
rename(table("comments"), :conversation_id, to: :discussion_id)
|
||||
|
||||
alter table(:actors) do
|
||||
add(:discussions_url, :string, null: true)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
rename(table("discussions"), to: table("conversations"))
|
||||
rename(table("comments"), :discussion_id, to: :conversation_id)
|
||||
|
||||
alter table(:actors) do
|
||||
remove(:discussions_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
defmodule Mobilizon.Storage.Repo.Migrations.AddUrlToConversation do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
# Just in case old name is used
|
||||
drop_if_exists(constraint(:comments, :comments_conversation_id_fkey))
|
||||
drop_if_exists(constraint(:comments, :comments_discussion_id_fkey))
|
||||
|
||||
alter table(:discussions, primary_key: false) do
|
||||
remove(:id)
|
||||
add(:id, :uuid, primary_key: true)
|
||||
add(:url, :string, null: false)
|
||||
end
|
||||
|
||||
alter table(:comments) do
|
||||
remove(:discussion_id)
|
||||
add(:discussion_id, references(:discussions, type: :uuid), null: true)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
drop_if_exists(constraint(:comments, :comments_conversation_id_fkey))
|
||||
drop_if_exists(constraint(:comments, :comments_discussion_id_fkey))
|
||||
|
||||
alter table(:discussions, primary_key: true) do
|
||||
remove(:id)
|
||||
add(:id, :serial, primary_key: true)
|
||||
remove(:url)
|
||||
end
|
||||
|
||||
alter table(:comments) do
|
||||
remove(:discussion_id)
|
||||
add(:discussion_id, references(:discussions, type: :serial), null: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user