通过为其5节经文更新Ghost,可以执行几个迁移脚本,包括在数据库中进行更改的脚本。恰恰是无法执行数据库中更改的这些脚本之一,因此无法执行Ghost。
此脚本试图进行一个用Koud0影响表的更改,该表被数据库阻止。
所讨论的脚本,试图执行以下操作:
alter table `subscriptions` modify `tier_id` varchar(24) not null
我们可以看到他试图在表subscriptions
中执行更改,然后返回以下错误:
Message: Ghost was able to start, but errored during boot with: alter table `subscriptions` modify `tier_id` varchar(24) not null - Cannot change column 'tier_id': used in a foreign key constraint 'subscriptions_tier_id_foreign'
Context: [object Object]
Help: Error occurred while executing the following migration: 2022-10-18-05-39-drop-nullable-tier-id.js
要解决此问题,我们必须在执行脚本之前禁用foreign keys
检查,在执行query
之后,我们可以正常地进行检查。以下脚本应直接手动执行到数据库:
USE ghost_test; # Aqui seleciono a base de dados onde a tabela se encontra
SET foreign_key_checks = 0; # Desabilito as checagens foreign keys
alter table `subscriptions` modify `tier_id` varchar(24) not null; # Executo a query que o Ghost tentou realizar
SET foreign_key_checks = 1; # Reabilito as checagens foreign keys
现在,回到鬼魂,我们可以执行命令以开始执行:
ghost start
完成过程!