Skip to content

Commit

Permalink
Feat/posttag migration (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanzeen authored Nov 2, 2024
1 parent 35c8ffe commit a98d487
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
11 changes: 11 additions & 0 deletions priv/repo/migrations/20241025203733_create_post_tag.exs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a98d487

Please sign in to comment.