我今天从1.2.0升级到1.3.2出现了数据库迁移报错,请问如何解决?
org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql failed
-------------------------------------------------------------
SQL State : 23505
Error Code : 23505
Message : Unique index or primary key violation: "UK_OUL14HO7BCTBEFV8JYWP5V3I2_INDEX_6 ON PUBLIC.CATEGORIES(SLUG) VALUES ('java', 23)"; SQL statement:
-- Migrate categories Table
update categories set `slug`=`slug_name` [23505-196]
Location : migration/V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql (/root/App/file:/root/App/halo-latest.jar!/BOOT-INF/classes!/migration/V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql)
Line : 9
Statement : -- Migrate categories Table
update categories set `slug`=`slug_name`
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:369) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.access$200(DbMigrate.java:54) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate$3.call(DbMigrate.java:282) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:279) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.access$100(DbMigrate.java:54) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:162) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:159) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.jdbc.TableLockingExecutionTemplate$1.call(TableLockingExecutionTemplate.java:37) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.jdbc.TableLockingExecutionTemplate.execute(TableLockingExecutionTemplate.java:33) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.database.base.Connection.lock(Connection.java:129) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:140) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:159) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:137) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.Flyway$1.execute(Flyway.java:193) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.Flyway$1.execute(Flyway.java:153) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.Flyway.execute(Flyway.java:523) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.Flyway.migrate(Flyway.java:153) ~[flyway-core-6.3.1.jar!/:na]
at run.halo.app.listener.StartedListener.migrate(StartedListener.java:100) ~[classes!/:na]
at run.halo.app.listener.StartedListener.onApplicationEvent(StartedListener.java:66) ~[classes!/:na]
at run.halo.app.listener.StartedListener.onApplicationEvent(StartedListener.java:40) ~[classes!/:na]
at run.halo.app.listener.StartedListener$$EnhancerBySpringCGLIB$$dbe63e2f.onApplicationEvent(<generated>) ~[classes!/:na]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:98) ~[spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:71) ~[spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
at run.halo.app.Application.main(Application.java:35) [classes!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_221]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_221]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [halo-latest.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [halo-latest.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [halo-latest.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [halo-latest.jar:na]
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException:
Migration V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql failed
-------------------------------------------------------------
SQL State : 23505
Error Code : 23505
Message : Unique index or primary key violation: "UK_OUL14HO7BCTBEFV8JYWP5V3I2_INDEX_6 ON PUBLIC.CATEGORIES(SLUG) VALUES ('java', 23)"; SQL statement:
-- Migrate categories Table
update categories set `slug`=`slug_name` [23505-196]
Location : migration/V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql (/root/App/file:/root/App/halo-latest.jar!/BOOT-INF/classes!/migration/V3__migrate_1.3.0-beta.1_to_1.3.0-beta.2.sql)
Line : 9
Statement : -- Migrate categories Table
update categories set `slug`=`slug_name`
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleException(DefaultSqlScriptExecutor.java:274) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:220) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(DefaultSqlScriptExecutor.java:127) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeOnce(SqlMigrationExecutor.java:88) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.access$000(SqlMigrationExecutor.java:33) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor$1.call(SqlMigrationExecutor.java:77) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor$1.call(SqlMigrationExecutor.java:74) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.database.DefaultExecutionStrategy.execute(DefaultExecutionStrategy.java:28) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:74) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:366) ~[flyway-core-6.3.1.jar!/:na]
... 42 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UK_OUL14HO7BCTBEFV8JYWP5V3I2_INDEX_6 ON PUBLIC.CATEGORIES(SLUG) VALUES ('java', 23)"; SQL statement:
-- Migrate categories Table
update categories set `slug`=`slug_name` [23505-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.196.jar!/:na]
at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.196.jar!/:na]
at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.196.jar!/:na]
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103) ~[h2-1.4.196.jar!/:na]
at org.h2.mvstore.db.MVSecondaryIndex.checkUnique(MVSecondaryIndex.java:231) ~[h2-1.4.196.jar!/:na]
at org.h2.mvstore.db.MVSecondaryIndex.add(MVSecondaryIndex.java:190) ~[h2-1.4.196.jar!/:na]
at org.h2.mvstore.db.MVTable.addRow(MVTable.java:705) ~[h2-1.4.196.jar!/:na]
at org.h2.table.Table.updateRows(Table.java:506) ~[h2-1.4.196.jar!/:na]
at org.h2.command.dml.Update.update(Update.java:145) ~[h2-1.4.196.jar!/:na]
at org.h2.command.CommandContainer.update(CommandContainer.java:101) ~[h2-1.4.196.jar!/:na]
at org.h2.command.Command.executeUpdate(Command.java:260) ~[h2-1.4.196.jar!/:na]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:192) ~[h2-1.4.196.jar!/:na]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:164) ~[h2-1.4.196.jar!/:na]
at org.flywaydb.core.internal.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:244) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.sqlscript.ParsedSqlStatement.execute(ParsedSqlStatement.java:111) ~[flyway-core-6.3.1.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:208) ~[flyway-core-6.3.1.jar!/:na]
... 50 common frames omitted
2020-04-14 22:36:11.700 INFO 27257 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2020-04-14 22:36:11.716 INFO 27257 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-04-14 22:36:11.717 INFO 27257 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-04-14 22:36:12.479 INFO 27257 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-04-14 22:36:12.483 INFO 27257 --- [ main] io.undertow : stopping server: Undertow - 2.0.29.Final