Skip to main content

v5 中缩短的数据库标识符

¥Database identifiers shortened in v5

在 Strapi 5 中,数据库标识符不能超过 55 个字符。

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

¥In Strapi 5, database identifiers can't be longer than 55 characters.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?Yes
(此重大更改实际上是由数据迁移脚本处理的,该脚本在你的 Strapi 项目升级到 Strapi 5 时运行。)

¥

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?Yes
(This breaking change is actually handled by a data migration script that runs when your Strapi project is upgraded to Strapi 5.)

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

数据库标识符可能超过 55 个字符,可能会导致某些数据库出现问题。

¥Database identifiers could be longer than 55 characters, potentially causing issues with some databases.

在 Strapi 5 中

¥In Strapi 5

数据库标识符不能超过 55 个字符,并且会被缩短。

¥Database identifiers can't be longer than 55 characters and will be shortened.

迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

注意

¥Notes

  • 缩短数据库标识符时将添加哈希键以避免冲突。它将由 SHA-256 的前 6 个字符组成。例如,在 Strapi v5 中,my_very_very_very_very_very_very_very_too_long_identifier_unique 将被缩短为 my_very_very_very_very_very_very_very_very_a2dx3_uq

    ¥A hashing key will be added when shortening database identifiers to avoid conflicts. It will consist in the first 6 characters of SHA-256. For example, my_very_very_very_very_very_very_very_too_long_identifier_unique will be shortened to my_very_very_very_very_very_very_very_very_a2dx3_uq in Strapi v5.

  • 将使用一些后缀:

    ¥Some suffixes will be used:

    后缀简短版本
    component_type_indexcmpix
    componentcmp
    componentscmps
    entity_fketfk
    field_indexflix
    fkfk
    id_column_indexidix
    indexidx
    inv_fkifk
    linkslnk
    morphsmph
    order_fkofk
    order_indexoidx
    order_inv_fkoifk
    orderord
    primarypk
    uniqueuq

手动程序

¥Manual procedure

在 Strapi v5 中启动应用时,Strapi 应该处理所有事情。

¥Strapi should handle everything when starting the application in Strapi v5.

但是,请注意,如果你对数据库表或列有硬编码引用,则可能需要手动更新它们。

¥However, be aware that if you have hard-coded references to database tables or columns, you may need to manually update them.