20250712021931_extension_eav_attribute.php 1.2 KB

1234567891011121314151617181920212223242526
  1. <?php
  2. use think\migration\Migrator;
  3. class ExtensionEavAttribute extends Migrator
  4. {
  5. /**
  6. * Change Method.
  7. *
  8. * Write your reversible migrations using this method.
  9. */
  10. public function change(): void
  11. {
  12. $this->table('extension_eav_attribute', ['engine' => 'InnoDB', 'charset' => 'utf8mb4', 'comment' => '属性定义表'])
  13. ->addColumn('entity_type_id', 'integer', ['signed' => false, 'comment' => '关联实体类型'])
  14. ->addColumn('attribute_code', 'string', ['comment' => '属性编码', 'limit' => 64])
  15. ->addColumn('backend_type', 'string', ['comment' => '存储类型(int/varchar/decimal/text), 需与frontend_input匹配', 'limit' => 8])
  16. ->addColumn('frontend_input', 'string', ['comment' => '表单控件类型', 'limit' => 16])
  17. ->addColumn('frontend_label', 'string', ['comment' => '显示标签', 'limit' => 255])
  18. ->addColumn('is_required', 'boolean', ['comment' => '是否必填', 'default' => false])
  19. ->addIndex(['entity_type_id', 'attribute_code'], ['unique' => true])
  20. ->addTimestamps()
  21. ->addSoftDelete()
  22. ->create();
  23. }
  24. }