magento2 - Magento 2.3 无法在数据库表中设置默认值 NULL
问题描述
我想将新列添加到愿望清单表中,类型为整数,默认值为 NULL,但 magento 将其设置为“0”。这是我的 db_schema.xml
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="wishlist" resource="default" engine="innodb" comment="Wishlist main Table">
<column xsi:type="int" name="new_column" padding="10" unsigned="true" nullable="true" identity="false"
default="NULL" comment="Customer ID"/>
<constraint xsi:type="foreign" referenceId="WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="wishlist"
column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id"
onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="WISHLIST_CUSTOMER_ID" disabled="true"/>
<index referenceId="WISHLIST_CUSTOMER_ID" indexType="btree">
<column name="customer_id"/>
</index>
</table>
</schema>
我可以在 phpmyadmin 中将默认值编辑为“NULL”,但我需要 Magento 自动执行此操作。提前致谢。
解决方案
您是否执行过设置:升级?
推荐阅读
- html -
- 显示数字和上 alpha 的子列表
- mysql - 将一个或多个列结构从一个表复制到另一个
- wpf - 我找不到 Telerik.Windows.Controls.Media 来使用 Telerik RadWebCam
- swift - 如何向 PassthroughSubject 发送错误?
- javascript - 通过遍历数组来更改innerHTML
- canvas - 在画布动画中反转球方向
- r - Factorminer 的 Hclust 对象不会在 Pheatmap 中聚类树状图
- javascript - React:如何从 useEffect 内部返回 useRef.current.value?
- python - 使用 df 列中的值从另一个 df 中查找名称
- python - 无法将列插入新创建的数据框(Python - Pandas)