Flyway script 第一次跳过后的第二个flyway脚本
Flyway script second flyway script after skipping first
Flyway 似乎跳过了我的 V1__Create_COST_DATA.sql 脚本,但尝试 运行 V1.2__ALTER_COST_DATA.sql 脚本。我确定我有这个错误,但这就是它在这一点上的样子,我不确定为什么。我查找了 SQLERROR 代码,它基本上意味着我指的是一个不存在的对象。这是真的,在我的 DB2INST1 模式中,我没有 COST_SSCDATA table.
这是 Java Spring 带有几个 DB2 数据库和 3 个模式的引导项目。
我尽力提供尽可能多的信息,但为了安全起见,出于 IP 原因更改了一些名称。
我的缩写堆栈跟踪:
...
Caused by: org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateSqlException:
Migration V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql failed
--------------------------------------------------------------------
SQL State : 42704
Error Code : -204
Message : DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2INST.COST_SSCDATA, DRIVER=4.19.66
Location : db/migration/V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql (C:\projects-new\cirrus-spreadsheet-service\target\classes\db\migration\V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql)
Line : 4
Statement : ALTER TABLE COST_SSCDATA
add column FILENAME varchar(100)
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup (DbMigrate.java:365)
at org.flywaydb.core.internal.command.DbMigrate.access0 (DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:297)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute (TransactionTemplate.java:75)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations (DbMigrate.java:294)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup (DbMigrate.java:259)
at org.flywaydb.core.internal.command.DbMigrate.access0 (DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:179)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:176)
at org.flywaydb.core.internal.database.Connection.call (Connection.java:155)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute (TransactionTemplate.java:75)
at org.flywaydb.core.internal.database.Connection.lock (Connection.java:151)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock (JdbcTableSchemaHistory.java:148)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll (DbMigrate.java:176)
at org.flywaydb.core.internal.command.DbMigrate.migrate (DbMigrate.java:145)
at org.flywaydb.core.Flyway.execute (Flyway.java:1206)
at org.flywaydb.core.Flyway.execute (Flyway.java:1168)
at org.flywaydb.core.Flyway.execute (Flyway.java:1655)
at org.flywaydb.core.Flyway.migrate (Flyway.java:1168)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet (FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1758)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1695)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=] (AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate (DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency (DefaultListableBeanFactory.java:1135)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency (DefaultListableBeanFactory.java:1062)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject (AutowiredAnnotationBeanPostProcessor.java:583)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean (AbstractAutowireCapableBeanFactory.java:1341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:572)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=] (AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:759)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:869)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:398)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1258)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1246)
at com.mycompany.myproject.cost.spreadsheet.CostSpreadsheetUploadWebApplication.main (CostSpreadsheetUploadWebApplication.java:32)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
at java.lang.Thread.run (Thread.java:834)
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2INST.COST_SSCDATA, DRIVER=4.19.66
V1__Create_COST_SSCDATA_Table.sql(缩写)
CREATE TABLE COST_SSCDATA
(
SSCDATAID bigint PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
PROCESSGROUPID bigint,
...
)
;
CREATE UNIQUE INDEX SQL180420024015740 ON COST_SSCDATA(SSCDATAID)
;
V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql
--
-- Add new field (FILENAME) to this table for storing name of the uploaded file (with extension)
--
ALTER TABLE COST_SSCDATA
add column FILENAME varchar(100);
flyway info
Flyway Community Edition 7.5.4 by Redgate
Database: jdbc:db2://localhost:50000/bcupload (DB2/LINUXX8664 11.5)
Schema version: 1
+-----------+---------+------------------------------------------------------------+----------+---------------------+----------+
| | 1 | << Flyway Baseline >> | BASELINE | 2021-03-02 06:25:36 | Baseline |
| Versioned | 1.1 | Create COST SPREADSHEET Table | SQL | | Pending |
| Versioned | 1.2 | ALTER COST SPREADSHEET Table ADD FILENAME | SQL | | Pending |
| Versioned | 1.3 | Create JOB5 EXECUTION Table | SQL | | Pending |
| Versioned | 1.4 | Create JOB5 EXECUTION SPREADSHEET Table | SQL | | Pending |
| Versioned | 1.5 | Create COST SPREADSHEET BACKUP Table | SQL | | Pending |
| Versioned | 1.6 | ALTER COST SPREADSHEET BACKUP Table ADD STATUS REASON | SQL | | Pending |
| Versioned | 1.7 | ALTER COST SPREADSHEET BACKUP Table UPDATE ORIG COMPANY CD | SQL | | Pending |
您似乎已将基线设置为 1,这意味着来自 v1 和更早版本的所有脚本都将被忽略。如果您将迁移脚本从 V1__Create_COST_DATA.sql 重命名为 V1。01__Create_COST_DATA.sql 您可能没问题!
Flyway 似乎跳过了我的 V1__Create_COST_DATA.sql 脚本,但尝试 运行 V1.2__ALTER_COST_DATA.sql 脚本。我确定我有这个错误,但这就是它在这一点上的样子,我不确定为什么。我查找了 SQLERROR 代码,它基本上意味着我指的是一个不存在的对象。这是真的,在我的 DB2INST1 模式中,我没有 COST_SSCDATA table.
这是 Java Spring 带有几个 DB2 数据库和 3 个模式的引导项目。
我尽力提供尽可能多的信息,但为了安全起见,出于 IP 原因更改了一些名称。
我的缩写堆栈跟踪:
...
Caused by: org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateSqlException:
Migration V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql failed
--------------------------------------------------------------------
SQL State : 42704
Error Code : -204
Message : DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2INST.COST_SSCDATA, DRIVER=4.19.66
Location : db/migration/V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql (C:\projects-new\cirrus-spreadsheet-service\target\classes\db\migration\V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql)
Line : 4
Statement : ALTER TABLE COST_SSCDATA
add column FILENAME varchar(100)
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup (DbMigrate.java:365)
at org.flywaydb.core.internal.command.DbMigrate.access0 (DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:297)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute (TransactionTemplate.java:75)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations (DbMigrate.java:294)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup (DbMigrate.java:259)
at org.flywaydb.core.internal.command.DbMigrate.access0 (DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:179)
at org.flywaydb.core.internal.command.DbMigrate.call (DbMigrate.java:176)
at org.flywaydb.core.internal.database.Connection.call (Connection.java:155)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute (TransactionTemplate.java:75)
at org.flywaydb.core.internal.database.Connection.lock (Connection.java:151)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock (JdbcTableSchemaHistory.java:148)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll (DbMigrate.java:176)
at org.flywaydb.core.internal.command.DbMigrate.migrate (DbMigrate.java:145)
at org.flywaydb.core.Flyway.execute (Flyway.java:1206)
at org.flywaydb.core.Flyway.execute (Flyway.java:1168)
at org.flywaydb.core.Flyway.execute (Flyway.java:1655)
at org.flywaydb.core.Flyway.migrate (Flyway.java:1168)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet (FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1758)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1695)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=] (AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate (DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency (DefaultListableBeanFactory.java:1135)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency (DefaultListableBeanFactory.java:1062)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject (AutowiredAnnotationBeanPostProcessor.java:583)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean (AbstractAutowireCapableBeanFactory.java:1341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:572)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=] (AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:759)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:869)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:398)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1258)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1246)
at com.mycompany.myproject.cost.spreadsheet.CostSpreadsheetUploadWebApplication.main (CostSpreadsheetUploadWebApplication.java:32)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
at java.lang.Thread.run (Thread.java:834)
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2INST.COST_SSCDATA, DRIVER=4.19.66
V1__Create_COST_SSCDATA_Table.sql(缩写)
CREATE TABLE COST_SSCDATA
(
SSCDATAID bigint PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
PROCESSGROUPID bigint,
...
)
;
CREATE UNIQUE INDEX SQL180420024015740 ON COST_SSCDATA(SSCDATAID)
;
V1.2__ALTER_COST_SPREADSHEET_Table_ADD_FILENAME.sql
--
-- Add new field (FILENAME) to this table for storing name of the uploaded file (with extension)
--
ALTER TABLE COST_SSCDATA
add column FILENAME varchar(100);
flyway info
Flyway Community Edition 7.5.4 by Redgate
Database: jdbc:db2://localhost:50000/bcupload (DB2/LINUXX8664 11.5)
Schema version: 1
+-----------+---------+------------------------------------------------------------+----------+---------------------+----------+
| | 1 | << Flyway Baseline >> | BASELINE | 2021-03-02 06:25:36 | Baseline |
| Versioned | 1.1 | Create COST SPREADSHEET Table | SQL | | Pending |
| Versioned | 1.2 | ALTER COST SPREADSHEET Table ADD FILENAME | SQL | | Pending |
| Versioned | 1.3 | Create JOB5 EXECUTION Table | SQL | | Pending |
| Versioned | 1.4 | Create JOB5 EXECUTION SPREADSHEET Table | SQL | | Pending |
| Versioned | 1.5 | Create COST SPREADSHEET BACKUP Table | SQL | | Pending |
| Versioned | 1.6 | ALTER COST SPREADSHEET BACKUP Table ADD STATUS REASON | SQL | | Pending |
| Versioned | 1.7 | ALTER COST SPREADSHEET BACKUP Table UPDATE ORIG COMPANY CD | SQL | | Pending |
您似乎已将基线设置为 1,这意味着来自 v1 和更早版本的所有脚本都将被忽略。如果您将迁移脚本从 V1__Create_COST_DATA.sql 重命名为 V1。01__Create_COST_DATA.sql 您可能没问题!