<?php

use think\migration\Migrator;

class CreateSysCountry 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()
    {
        $table = $this->table('sys_country', ['engine' => 'MyISAM', 'comment' => '国家表']);
        $table->addColumn('name', 'string', ['limit' => 120, 'null' => false, 'default' => '', 'comment' => '国家名称'])
            ->addColumn('en_name', 'string', ['limit' => 120, 'null' => true, 'default' => null, 'comment' => '国家英文名称'])
            ->addColumn('code', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '国家代码'])
            ->addColumn('icon', 'string', ['limit' => 64, 'default' => null, 'comment' => '国家图标'])
            ->addColumn('status', 'boolean', ['default' => 1, 'comment' => '状态:1启用,0禁用'])
            ->addColumn('sort', 'integer', ['default' => 0, 'comment' => '排序'])
            ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
            ->addColumn('updated_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
            ->create();
    }
}
