diff --git a/lib/pescarte/blog/post.ex b/lib/pescarte/blog/post.ex index 5cfcac0a..08dfe087 100644 --- a/lib/pescarte/blog/post.ex +++ b/lib/pescarte/blog/post.ex @@ -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] @@ -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() @@ -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 diff --git a/lib/pescarte/identidades/models/usuario.ex b/lib/pescarte/identidades/models/usuario.ex index b8a10941..9809baa0 100644 --- a/lib/pescarte/identidades/models/usuario.ex +++ b/lib/pescarte/identidades/models/usuario.ex @@ -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 @@ -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 diff --git a/logfile b/logfile index f5981dcd..ca4a30ac 100644 --- a/logfile +++ b/logfile @@ -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 diff --git a/priv/repo/migrations/20241122115106_create_posts_tags_relation.exs b/priv/repo/migrations/20241122115106_create_posts_tags_relation.exs index c2935d5b..035f4ca4 100644 --- a/priv/repo/migrations/20241122115106_create_posts_tags_relation.exs +++ b/priv/repo/migrations/20241122115106_create_posts_tags_relation.exs @@ -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