| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- declare(strict_types=1);
- use Phinx\Migration\AbstractMigration;
- class Hello extends AbstractMigration
- {
- /**
- * 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()
- {
- $table = $this->table('extension_hello', [
- 'comment' => 'hello测试表',
- 'engine' => 'InnoDB',
- 'collation' => 'utf8mb4_general_ci',
- 'id' => false,
- 'primary_key' => 'id'
- ]);
- $table->addColumn('id', 'string', [
- 'limit' => 50,
- 'null' => false,
- 'comment' => '唯一标识符'
- ])->addColumn('name', 'string', [
- 'limit' => 100,
- 'null' => false,
- 'comment' => '名称'
- ])->addColumn('update_time', 'datetime', [
- 'null' => true,
- 'comment' => '更新时间'
- ])->addColumn('delete_time', 'datetime', [
- 'null' => true,
- 'comment' => '删除时间'
- ])->addIndex(['id'], [
- 'unique' => true,
- 'name' => 'uniq_id'
- ])->create();
- }
- }
|