Introduce group posts

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-07-09 17:24:28 +02:00
parent bec1c69d4b
commit 9c9f1385fb
249 changed files with 11886 additions and 5023 deletions

View 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