Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/posttag migration #230

Merged
merged 15 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading