20250712021931_extension_eva_attribute.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use think\migration\Migrator;
  3. class ExtensionEvaAttribute extends Migrator
  4. {
  5. /**
  6. * Change Method.
  7. *
  8. * Write your reversible migrations using this method.
  9. *
  10. * More information on writing migrations is available here:
  11. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  12. *
  13. * The following commands can be used in this method and Phinx will
  14. * automatically reverse them when rolling back:
  15. *
  16. * createTable
  17. * renameTable
  18. * addColumn
  19. * renameColumn
  20. * addIndex
  21. * addForeignKey
  22. *
  23. * Remember to call "create()" or "update()" and NOT "save()" when working
  24. * with the Table class.
  25. */
  26. public function change(): void
  27. {
  28. $this->table('extension_eva_attribute', ['engine' => 'InnoDB', 'charset' => 'utf8mb4', 'comment' => '属性定义表'])
  29. ->addColumn('entity_type_id', 'integer', ['comment' => '关联实体类型'])
  30. ->addColumn('attribute_code', 'string', ['comment' => '属性编码', 'limit' => 64])
  31. ->addColumn('backend_type', 'string', ['comment' => '存储类型(int/varchar/decimal/text), 需与frontend_input匹配', 'limit' => 8])
  32. ->addColumn('frontend_input', 'string', ['comment' => '表单控件类型', 'limit' => 16])
  33. ->addColumn('frontend_label', 'string', ['comment' => '显示标签', 'limit' => 255])
  34. ->addColumn('is_required', 'boolean', ['comment' => '是否必填', 'default' => false])
  35. ->addIndex(['entity_type_id', 'attribute_code'], ['unique' => true])
  36. ->addTimestamps()
  37. ->addSoftDelete()
  38. ->create();
  39. }
  40. }