• 请求帮助
  • 手贱降版本了,再次升级回去出现SQL问题,帮忙看下是否还有机会恢复

Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException: Migration V6__migrate_create_contents_table.sql failed

SQL State : 23000
Error Code : 1062
Message : Duplicate entry '2' for key 'PRIMARY'
Location : migration/V6migrate_create_contents_table.sql (/file:/halo.jar!/BOOT-INF/classes!/migration/V6migrate_create_contents_table.sql)
Line : 2
Statement : -- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts

2022-05-11 00:45:24.261 ERROR 1 --- [ main] o.f.core.internal.command.DbMigrate : Migration of schema halo to version "6 - migrate create contents table" failed! Please restore backups and roll back database and code!
2022-05-11 00:45:24.276 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-05-11 00:45:24.322 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V6__migrate_create_contents_table.sql failed

SQL State : 23000
Error Code : 1062
Message : Duplicate entry '2' for key 'PRIMARY'
Location : migration/V6migrate_create_contents_table.sql (/file:/halo.jar!/BOOT-INF/classes!/migration/V6migrate_create_contents_table.sql)
Line : 2
Statement : -- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts

用的MySQL,没有之前的SQL备份

这个方案恢复失败,通过RDS的自动备份恢复到正常状态了。
后台导出的markdown文本,只包含文章标题标签,是没有内容的,内容全在数据库里写的,这个markdown导出是不是有些问题呢

是否支持MySQL迁移至H2呢

    ZTfred

    后台导出的markdown文本,只包含文章标题标签,是没有内容的,内容全在数据库里写的,这个markdown导出是不是有些问题呢

    这个问题没有复现,请问你当前的版本是?

    是否支持MySQL迁移至H2呢

    支持,在后台小工具里面导出数据,然后在初始化的时候导入即可。参考 https://docs.halo.run/user-guide/backup-migration

      Ryan Wang 👍 1.5.3版本,旧文章没问题,昨天新写的没有倒出来,只有站点标签,标题信息😂数据库修复后得重写一遍了