<?php

use think\migration\Migrator;

class CreateProductTcoCategory 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('product_tco_category', ['engine' => 'InnoDB', 'comment' => '产品目录分类同步记录表']);
        $table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID'])
            ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '分类名称'])
            ->addColumn('tco_id', 'integer', ['default' => null, 'comment' => '产品目录分类ID'])
            ->addColumn('tco_pid', 'integer', ['default' => null, 'comment' => '产品目录分类父级ID'])
            ->addColumn('tco_path', 'string', ['limit' => 120, 'default' => null, 'comment' => '产品目录分类上下级关联路径'])
            ->addColumn('erp_id',  'integer', ['default' => null, 'comment' => '分类在ERP中的ID'])
            ->addColumn('erp_pid', 'integer', ['default' => null, 'comment' => '分类在ERP中的父级ID'])
            ->addColumn('erp_code', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '分类在ERP中的编码'])
            ->addColumn('erp_path', 'string', ['limit' => 120, 'default' => null, 'comment' => '分类在ERP中的上下级关联路径'])
            ->addColumn('disabled', 'boolean', ['null' => false, 'default' => 0, 'comment' => '0为启用, 1为禁用'])
            ->addColumn('sync_time', 'integer', ['null' => false, 'default' => 0, 'comment' => '同步时间'])
            ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '新增时间'])
            ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
            ->addColumn('deleted_at', 'timestamp', ['null' => true, 'comment' => '删除时间'])
            ->create();
    }
}