Skip to content

Commit

Permalink
pain
Browse files Browse the repository at this point in the history
  • Loading branch information
juanzeen committed Dec 9, 2024
1 parent 7853cf7 commit 3ef2629
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lib/pescarte/blog/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ defmodule Pescarte.Blog.Post do
published_at: NaiveDateTime.t(),
inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t(),
usuario_id: String.t(),
usuario: Usuario.t()
usuario: Usuario.t(),
usuario_id: String.t()
}

@required_params [:titulo, :conteudo, :link_imagem_capa, :published_at, :usuario_id]
Expand All @@ -30,8 +30,9 @@ defmodule Pescarte.Blog.Post do
field :conteudo, :binary
field :link_imagem_capa, :string
field :published_at, :naive_datetime
field :usuario_id, :string

belongs_to :usuario, Usuario, foreign_key: :usuario_id
belongs_to :usuario, Usuario, type: :string, foreign_key: true
many_to_many :blog_tags, Tag, join_through: "posts_tags"

timestamps()
Expand Down Expand Up @@ -71,7 +72,7 @@ defmodule Pescarte.Blog.Post do
on_conflict: :replace_all,
conflict_target: :nome
)
|> Multi.insert(:blog_post, Post.changeset(%Post{}, params))
|> Multi.insert(:blog_posts, changeset(%Post{}, params))
|> Repo.transaction()
end

Expand Down
4 changes: 2 additions & 2 deletions lib/pescarte/identidades/models/usuario.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Pescarte.Identidades.Models.Usuario do

import Brcpfcnpj.Changeset, only: [validate_cpf: 3]

# alias Pescarte.Blog.Post
alias Pescarte.Blog.Post
alias Pescarte.Database.Types.PublicId
alias Pescarte.Identidades.Models.Contato
alias Pescarte.ModuloPesquisa.Models.Pesquisador
Expand Down Expand Up @@ -45,7 +45,7 @@ defmodule Pescarte.Identidades.Models.Usuario do

belongs_to :contato, Contato, type: :string

has_many :blog_post, Post
has_many :blog_posts, Post

timestamps()
end
Expand Down
15 changes: 15 additions & 0 deletions logfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@
2024-11-22 00:43:02.164 -03 [600000] WARNING: could not create listen socket for "localhost"
2024-11-22 00:43:02.164 -03 [600000] FATAL: could not create any TCP/IP sockets
2024-11-22 00:43:02.168 -03 [600000] LOG: database system is shut down
2024-12-09 11:12:16.400 -03 [66538] LOG: starting PostgreSQL 14.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
2024-12-09 11:12:16.401 -03 [66538] LOG: could not bind IPv4 address "127.0.0.1": Endereço já em uso
2024-12-09 11:12:16.401 -03 [66538] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2024-12-09 11:12:16.401 -03 [66538] WARNING: could not create listen socket for "localhost"
2024-12-09 11:12:16.401 -03 [66538] FATAL: could not create any TCP/IP sockets
2024-12-09 11:12:16.402 -03 [66538] LOG: database system is shut down
2024-12-09 17:49:04.615 -03 [48679] LOG: starting PostgreSQL 14.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
2024-12-09 17:49:04.615 -03 [48679] LOG: listening on IPv4 address "127.0.0.1", port 5432
2024-12-09 17:49:04.618 -03 [48679] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-12-09 17:49:04.623 -03 [48680] LOG: database system was shut down at 2024-12-09 17:45:55 -03
2024-12-09 17:49:04.628 -03 [48679] LOG: database system is ready to accept connections
2024-12-09 18:13:07.831 -03 [81937] FATAL: role "peapescarte" does not exist
2024-12-09 18:13:07.831 -03 [81936] FATAL: role "peapescarte" does not exist
2024-12-09 18:13:09.414 -03 [82013] FATAL: role "peapescarte" does not exist
2024-12-09 18:13:09.764 -03 [82038] FATAL: role "peapescarte" does not exist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Pescarte.Database.Repo.Migrations.CreatePostTags do
create table(:posts_tags_relation, primary_key: :false) do
add :id, :string, primary_key: :true
add :tag_id, references(:blog_tag, type: :string), null: false
add :post_id, references(:blog_post, type: :string), null: false
add :post_id, references(:blog_posts, type: :string), null: false
timestamps()
end
end
Expand Down

0 comments on commit 3ef2629

Please sign in to comment.