{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2753","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2753/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2753/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2753/events","html_url":"https://github.com/spring-projects/spring-boot/issues/2753","id":65292174,"number":2753,"title":"Spring Boot does not execute data.sql when using Flyway","user":{"login":"derylseale","id":1426718,"avatar_url":"https://avatars.githubusercontent.com/u/1426718?v=3","gravatar_id":"","url":"https://api.github.com/users/derylseale","html_url":"https://github.com/derylseale","followers_url":"https://api.github.com/users/derylseale/followers","following_url":"https://api.github.com/users/derylseale/following{/other_user}","gists_url":"https://api.github.com/users/derylseale/gists{/gist_id}","starred_url":"https://api.github.com/users/derylseale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derylseale/subscriptions","organizations_url":"https://api.github.com/users/derylseale/orgs","repos_url":"https://api.github.com/users/derylseale/repos","events_url":"https://api.github.com/users/derylseale/events{/privacy}","received_events_url":"https://api.github.com/users/derylseale/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2015-03-30T20:11:45Z","updated_at":"2016-09-05T12:32:39Z","closed_at":null,"body":"When I include the Flyway library in my classpath, Spring Boot correctly locates and executes my migrations. It does not, however, make use of my data.sql script, which I use to import fixture data for unit tests. Per the documentation, I am setting the `jpa.hibernate.ddl-auto` property to `false` so that Hibernate doesn't try to generate the schema itself. If I remove this property, then Spring boot *does* load the data.sql file, but Hibernate is also clearly trying to generate the schema redundantly, which is at the very least unnecessary but also probably error prone.\r\n\r\nIs there a way to use Flyway along with the normal Spring Boot datasource initialization features?\r\n\r\n````\r\n2015-03-30 16:04:09.851  INFO 56097 --- [    Test worker] o.f.core.internal.util.VersionPrinter    : Flyway 3.2.1 by Boxfuse\r\n2015-03-30 16:04:10.113  INFO 56097 --- [    Test worker] o.f.c.i.dbsupport.DbSupportFactory       : Database: jdbc:h2:mem:testdb (H2 1.4)\r\n2015-03-30 16:04:10.169  INFO 56097 --- [    Test worker] o.f.core.internal.command.DbValidate     : Validated 2 migrations (execution time 00:00.013s)\r\n2015-03-30 16:04:10.183  INFO 56097 --- [    Test worker] o.f.c.i.metadatatable.MetaDataTableImpl  : Creating Metadata table: \"PUBLIC\".\"schema_version\"\r\n2015-03-30 16:04:10.209  INFO 56097 --- [    Test worker] o.f.core.internal.command.DbMigrate      : Current version of schema \"PUBLIC\": << Empty Schema >>\r\n2015-03-30 16:04:10.209  INFO 56097 --- [    Test worker] o.f.core.internal.command.DbMigrate      : Migrating schema \"PUBLIC\" to version 1 - create user info tables\r\n2015-03-30 16:04:10.242  INFO 56097 --- [    Test worker] o.f.core.internal.command.DbMigrate      : Migrating schema \"PUBLIC\" to version 2 - create recipe tables\r\n2015-03-30 16:04:10.251  INFO 56097 --- [    Test worker] o.f.core.internal.command.DbMigrate      : Successfully applied 2 migrations to schema \"PUBLIC\" (execution time 00:00.070s).\r\n2015-03-30 16:04:10.364  INFO 56097 --- [    Test worker] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'\r\n2015-03-30 16:04:10.378  INFO 56097 --- [    Test worker] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [\r\n\tname: default\r\n\t...]\r\n2015-03-30 16:04:10.490  INFO 56097 --- [    Test worker] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.8.Final}\r\n2015-03-30 16:04:10.492  INFO 56097 --- [    Test worker] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found\r\n2015-03-30 16:04:10.495  INFO 56097 --- [    Test worker] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist\r\n2015-03-30 16:04:10.795  INFO 56097 --- [    Test worker] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}\r\n2015-03-30 16:04:10.853  INFO 56097 --- [    Test worker] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect\r\n2015-03-30 16:04:10.990  INFO 56097 --- [    Test worker] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory\r\n2015-03-30 16:04:11.255  INFO 56097 --- [    Test worker] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export\r\n2015-03-30 16:04:11.267  INFO 56097 --- [    Test worker] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete\r\n2015-03-30 16:04:11.348  INFO 56097 --- [    Test worker] o.s.jdbc.datasource.init.ScriptUtils     : Executing SQL script from URL [file:/redacted/main/data.sql]\r\n````"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/244736172","html_url":"https://github.com/spring-projects/spring-boot/issues/2753#issuecomment-244736172","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2753","id":244736172,"user":{"login":"vayalaivadivel","id":15357100,"avatar_url":"https://avatars.githubusercontent.com/u/15357100?v=3","gravatar_id":"","url":"https://api.github.com/users/vayalaivadivel","html_url":"https://github.com/vayalaivadivel","followers_url":"https://api.github.com/users/vayalaivadivel/followers","following_url":"https://api.github.com/users/vayalaivadivel/following{/other_user}","gists_url":"https://api.github.com/users/vayalaivadivel/gists{/gist_id}","starred_url":"https://api.github.com/users/vayalaivadivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vayalaivadivel/subscriptions","organizations_url":"https://api.github.com/users/vayalaivadivel/orgs","repos_url":"https://api.github.com/users/vayalaivadivel/repos","events_url":"https://api.github.com/users/vayalaivadivel/events{/privacy}","received_events_url":"https://api.github.com/users/vayalaivadivel/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T12:32:39Z","updated_at":"2016-09-05T12:32:39Z","body":"Hi, I getting below error while running spring boot with flyway and postgres sql. Any one can please help on to fix this issue,\r\n\r\nCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed: Detected resolved migration not applied to database: 1.0\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)\r\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)\r\n\tat org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)\r\n\tat org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:307)\r\n\tat org.springframework.boot.test.SpringApplicationContextLoader.loadContext(SpringApplicationContextLoader.java:98)\r\n\tat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)\r\n\tat org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)\r\n\t... 25 more\r\nCaused by: org.flywaydb.core.api.FlywayException: Validate failed: Detected resolved migration not applied to database: 1.0\r\n\tat org.flywaydb.core.Flyway.doValidate(Flyway.java:1000)\r\n\tat org.flywaydb.core.Flyway.access$100(Flyway.java:72)\r\n\tat org.flywaydb.core.Flyway$2.execute(Flyway.java:974)\r\n\tat org.flywaydb.core.Flyway$2.execute(Flyway.java:971)\r\n\tat org.flywaydb.core.Flyway.execute(Flyway.java:1361)\r\n\r\nThanks and Regards,\r\nVADIVEL"}}
{"actor":{"display_login":"vayalaivadivel"}}