Projeto flyway - resolvido

No projeto que estamos criando, em local, ao inicial o JPA - hibernate, criava as tabelas e inseria algumas informações, para testes.

Bom o projeto foi crescendo e decidimos incluir o flyway para versionamento de tabelas, já que vimos que este projeto faz isso.

Antes de colocarmos o flyway , o application_core.properties era assim:

spring.datasource.url=jdbc:postgresql://localhost/usuarios
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=

spring.jpa.hibernate.ddl-auto=create
spring.data.rest.base-path=/usuarios/api
server.port=8090

spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false
spring.jpa.properties.org.hibernate.envers.default_schema=event_log

logging.level.root=INFO
logging.level.org.hibernate.SQL=INFO
logging.level.org.springframework=INFO

Isto é, ao iniciar o servidor, ele automaticamente criava as table, index, constraint no banco de dados.

agora é assim:

spring.datasource.url=jdbc:postgresql://localhost/usuarios
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=

spring.jpa.hibernate.ddl-auto=none
spring.data.rest.base-path=/usuarios/api
server.port=8090

spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false
spring.jpa.properties.org.hibernate.envers.default_schema=event_log

logging.level.root=INFO
logging.level.org.hibernate.SQL=INFO
logging.level.org.springframework=INFO

Isto é, a propriedade spring.jpa.hibernate.ddl-auto era create e passou a ser none.

Só que mesmo passando a spring.jpa.hibernate.ddl-auto para none, o JPA - hibernate está criando as tabelas, automaticamente.

O projeto está divido em módulos core, rest, util e flyway.

Em cada módulo tem uma configuração:

Módulo flyway:

@Configuration
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoFlyway.PACOTE)
@ComponentScan({ ConfiguracaoFlyway.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoFlyway.PACOTE)
@PropertySource("classpath:application_flyway.properties")
public class ConfiguracaoFlyway {
	static final String PACOTE = "br.com.ghsistemas.usuarios.flyway";
}

Módulo core:

@Configuration
@EnableJpaAuditing
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoCore.PACOTE)
@ComponentScan({ ConfiguracaoCore.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoCore.PACOTE)
@PropertySource("classpath:application_core.properties")
public class ConfiguracaoCore {
	static final String PACOTE = "br.com.ghsistemas.usuarios.core";
}

O application_flyway.properties está assim:

flyway.driver=org.postgresql.Driver
flyway.urll=jdbc:postgresql://localhost/usuarios
flyway.user=postgres
flyway.password=
flyway.schemas=public

O que pode ser ?

E o trecho que eu deixei em negrito? Ele serve pra quê?
Dá ideia de criar as tabelas também.

spring.jpa.show-sql=true - Este mostra no console os comandos sql.

spring.jpa.generate-ddl=true, acho que o problema pode ser esse. Vou testar

Olá @guilhermebhte você tem que desabilitar a inicialização do flyway
no application_core.properties adicione

spring.flyway.enabled=false

Desabilitar Flyway na inicialização

É ao contrário @JeffersonSO

Eu preciso que o flyway executa e o jpa hibernate, na inicialização não

Deu certo, @guilhermebhte?

Tem que ver se já não é Flyway já criando as tabelas (caso tenha script de CREATE TABLE).

Assim funcionou

spring.jpa.generate-ddl=false

Ele pega os arquivos do flyway e não do JPA - hibernate

Obrigado @lucas.sampaio

1 curtida