20250712022607_extension_eva_value.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class ExtensionEvaValue extends Migrator
  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_eva_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', ['limit' => 11, 'default' => 0, 'comment' => '属性ID'])
  33. ->addColumn('value_int', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '整数值'])
  34. ->addColumn('value_varchar', 'string', ['limit' => 255, 'default' => '', 'comment' => '字符串值'])
  35. ->addColumn('value_decimal', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '数值值'])
  36. ->addColumn('value_text', 'text', ['comment' => '文本值'])
  37. ->addColumn('value_datetime', 'datetime', ['comment' => '日期时间值'])
  38. ->addIndex(['entity_id', 'attribute_id'], ['name' => 'entity_id_attribute_id', 'unique' => true])
  39. ->addTimestamps()
  40. ->addSoftDelete()
  41. ->create();
  42. }
  43. }