| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- class ExtensionEavValue extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change(): void
- {
- $table = $this->table('extension_eav_value', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '扩展:EAV值表']);
- $table
- ->addColumn('entity_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '实体ID'])
- ->addColumn('attribute_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '属性ID'])
- ->addColumn('entity_type_id', 'integer', ['signed' => false, 'default' => 0, 'comment' => '实体类型ID'])
- ->addColumn('value_int', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '整数值'])
- ->addColumn('value_varchar', 'string', ['limit' => 255, 'default' => '', 'comment' => '字符串值'])
- ->addColumn('value_decimal', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '数值值'])
- ->addColumn('value_text', 'text', ['comment' => '文本值'])
- ->addColumn('value_datetime', 'datetime', ['comment' => '日期时间值'])
- ->addIndex(['entity_id', 'attribute_id'], ['name' => 'entity_id_attribute_id'])
- ->addIndex(['entity_id', 'entity_type_id'],['name' => 'idx_entity_id_entity_type_id'])
- ->addTimestamps()
- ->addSoftDelete()
- ->create();
- }
- }
|