1
resposta

[Bug] Postgress pulando inicializacao [relation "curso" does not exist, skipping]

Fiz a configuração do ambiente conforme orientado no vídeo. Ao executar o docker compose up na linha de comando, tenho a seguinte saída:

msrn@DESK-MAURICIO:~/confiabilidade/api-logs$ sudo docker compose up
[+] Running 1/0
 ⠿ Container database-api-cursos  Recreated                                                                        0.1s
Attaching to database-api-cursos
database-api-cursos  |
database-api-cursos  | PostgreSQL Database directory appears to contain a database; Skipping initialization
database-api-cursos  |
database-api-cursos  | 2023-04-11 20:56:11.496 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
database-api-cursos  | 2023-04-11 20:56:11.496 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
database-api-cursos  | 2023-04-11 20:56:11.496 UTC [1] LOG:  listening on IPv6 address "::", port 5432
database-api-cursos  | 2023-04-11 20:56:11.501 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
database-api-cursos  | 2023-04-11 20:56:11.507 UTC [29] LOG:  database system was shut down at 2023-04-11 20:45:56 UTC
database-api-cursos  | 2023-04-11 20:56:11.512 UTC [1] LOG:  database system is ready to accept connections

Notei o seguinte apontamento :

PostgreSQL Database directory appears to contain a database; Skipping initialization

Mesmo assim tentei iniciar a aplicação no eclipse, consigo subir mas tenho a seguinte saida no console.

2023-04-11 18:02:11.325  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2023-04-11 18:02:11.325  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "curso" does not exist, skipping
2023-04-11 18:02:11.327  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2023-04-11 18:02:11.327  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "curso" does not exist, skipping
2023-04-11 18:02:11.328  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2023-04-11 18:02:11.328  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "curso" does not exist, skipping
2023-04-11 18:02:11.329  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2023-04-11 18:02:11.329  WARN 37444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "curso" does not exist, skipping
2023-04-11 18:02:11.330  INFO 37444 --- [  restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-04-11 18:02:11.339  INFO 37444 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-04-11 18:02:11.863  WARN 37444 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-04-11 18:02:12.300  INFO 37444 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-04-11 18:02:12.307  INFO 37444 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 4 endpoint(s) beneath base path '/actuator'
2023-04-11 18:02:12.352  INFO 37444 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-04-11 18:02:12.370  INFO 37444 --- [  restartedMain] br.com.alura.logs.CursoApplication       : Started CursoApplication in 5.074 seconds (JVM running for 5.618)

As requisições via postman, consequentemente também apresentam erros.

1 resposta

Olá! Tudo bem com você? Espero que sim!

Peço desculpa pela demora para responder o seu tópico.

O erro "PostgreSQL Database directory appears to contain a database; Skipping initialization" é uma mensagem informativa do PostgreSQL no Docker que indica que os dados do banco de dados já existem no volume do Docker e, portanto, a inicialização do banco de dados está sendo ignorada. Isso é normal se você já inicializou o banco de dados anteriormente.

Você precisa remover os volumes configurados para armazenar o banco de dados. Então você pode solicitar a remoção de volume assim:

docker-compose down --volumes

Espero ter ajudado. Caso tenha problemas ou dúvidas relacionados com este tópico, estarei à disposição para ajudar.

Grande abraço e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓.