2017-07-16 41 views
0

概述迁飞问题删除表时,申请停止

我要去飞行用分贝迁移添加到现有项目具有以下CONFIGS:

  • 项目类型:春季启动
  • DB:MariaDB的

应用local.yaml(迁飞和数据源CONFIGS):

... 

    flyway: 
     enabled: true 
     locations: classpath:db.migration 
     baselineOnMigrate: true 

    spring: 
     jackson: 
      serialization: 
       indent_output: true 
     devtools: 
      restart: 
       enabled: false 
      livereload: 
       enabled: false 
     datasource: 
      type: com.zaxxer.hikari.HikariDataSource 
      url: jdbc:mariadb://localhost:3306/migration 
      username: root 
      password: testing1 
      hikari: 
       data-source-properties: 
        leakDetectionThreshold: 2000 
        cachePrepStmts: true 
        prepStmtCacheSize: 250 
        prepStmtCacheSqlLimit: 2048 
        useServerPrepStmts: true 
     jpa: 
      database-platform: org.hibernate.dialect.MySQL5Dialect 
      database: MYSQL 
      show-sql: false 
      hibernate.id.new_generator_mappings: true 
      properties: 
       hibernate.cache.use_second_level_cache: false 
       hibernate.cache.use_query_cache: false 
       hibernate.generate_statistics: false 
       hibernate.hbm2ddl.import_files: schema-mysql.sql 
       hibernate.hbm2ddl.import_files_sql_extractor: org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor 
      open-in-view: false 
      hibernate: 
       ddl-auto: create-drop 
       naming: 
        physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy 
        implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy 
    ... 

问题:

当应用程序停止时,数据库表中不掉线。但正如我使用ddl-auto: create-drop,它预计表将被删除。

注意:我知道使用Flyway对于易失性数据库似乎有点奇怪。由于有些配置类在启动时插入初始数据。如果在应用程序已停止该数据库也不会落下,它会拿出抱怨[例如: - 唯一约束冲突]在接下来的启动,因为初始值已插入。

我会很感激,如果有人能帮助我与他们的真正解决方案。

回答

0

documentation for create-drop状态:

撤销模式并重新创建它在SessionFactory启动。另外,在SessionFactory关闭时删除模式。

你如何阻止你的应用程序?我猜你是不是关闭SessionFactory当你停止的应用程序

也许你会想在/shutdown端点添加到您的spring-boot应用程序指定here到正常关闭应用程序