20250712022607_extension_eav_value.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class ExtensionEavValue extends AbstractMigration
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change(): void
  28. {
  29. $table = $this->table('extension_eav_value', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '扩展:EAV值表']);
  30. $table
  31. ->addColumn('entity_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '实体ID'])
  32. ->addColumn('attribute_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '属性ID'])
  33. ->addColumn('entity_type_id', 'integer', ['signed' => false, 'default' => 0, 'comment' => '实体类型ID'])
  34. ->addColumn('value_int', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '整数值'])
  35. ->addColumn('value_varchar', 'string', ['limit' => 255, 'default' => '', 'comment' => '字符串值'])
  36. ->addColumn('value_decimal', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '数值值'])
  37. ->addColumn('value_text', 'text', ['comment' => '文本值'])
  38. ->addColumn('value_datetime', 'datetime', ['comment' => '日期时间值'])
  39. ->addIndex(['entity_id', 'attribute_id'], ['name' => 'entity_id_attribute_id'])
  40. ->addIndex(['entity_id', 'entity_type_id'],['name' => 'idx_entity_id_entity_type_id'])
  41. ->addTimestamps('create_time', 'update_time')
  42. ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间'])
  43. ->create();
  44. }
  45. }