<?php

use think\migration\Migrator;

class CreateSysLanguage 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_language', ['engine' => 'MyISAM', 'comment' => '语言表']);
        $table->addColumn('country_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '国家ID'])
            ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '语言名称'])
            ->addColumn('en_name', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '语言名称英文'])
            ->addColumn('code', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '语言编码'])
            ->addColumn('icon', 'string', ['limit' => 64, 'default' => null, 'comment' => '语言图标'])
            ->addColumn('url', 'string', ['limit' => 125, 'default' => null, 'comment' => '切换后访问的url'])
            ->addColumn('status', 'boolean', ['null' => false,'default' => 1, 'comment' => '状态:1启用,0禁用'])
            ->addColumn('is_default', 'boolean', ['null' => false, 'default' => 0, '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();
    }
}
