diff --git a/priv/repo/migrations/20240814205931_create_post.exs b/priv/repo/migrations/20241025203509_create_blog_posts.exs similarity index 65% rename from priv/repo/migrations/20240814205931_create_post.exs rename to priv/repo/migrations/20241025203509_create_blog_posts.exs index f46c9aae..b4db4bb7 100644 --- a/priv/repo/migrations/20240814205931_create_post.exs +++ b/priv/repo/migrations/20241025203509_create_blog_posts.exs @@ -2,7 +2,8 @@ defmodule Pescarte.Database.Repo.Migrations.CreatePost do use Ecto.Migration def change do - create table(:posts) do + create table(:blog_posts, primary_key: false) do + add :id, :string, primary_key: true add :user_id, references(:usuario, type: :string), null: false add :titulo, :string add :conteudo, :binary @@ -12,7 +13,7 @@ defmodule Pescarte.Database.Repo.Migrations.CreatePost do timestamps() end - create unique_index(:posts, :titulo) - create index(:posts, :user_id) + create unique_index(:blog_posts, :titulo) + create index(:blog_posts, :user_id) end end diff --git a/priv/repo/migrations/20241025203733_create_post_tag.exs b/priv/repo/migrations/20241025203733_create_post_tag.exs new file mode 100644 index 00000000..748048e3 --- /dev/null +++ b/priv/repo/migrations/20241025203733_create_post_tag.exs @@ -0,0 +1,11 @@ +defmodule Pescarte.Database.Repo.Migrations.CreatePostTags do + use Ecto.Migration + + def change do + create table(:post_tag) do + add :tag_id, references(:blog_tag, type: :string), null: false + add :post_id, references(:blog_posts, type: :string), null: false + timestamps() + end + end +end