Files
orico-official-website/database/migrations/20241218064708_create_product.php

57 lines
3.6 KiB
PHP

<?php
use think\migration\Migrator;
class CreateProduct 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', ['engine' => 'InnoDB', 'comment' => '产品表']);
$table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID'])
->addColumn('category_id', 'integer', ['signed' => false , 'null' => true, 'comment' => '分类ID'])
->addColumn('spu', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品规格'])
->addColumn('name', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '产品名称'])
->addColumn('short_name', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品简称'])
->addColumn('cover_image', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品封面图片'])
->addColumn('desc', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品描述'])
->addColumn('video_img', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品视频封面'])
->addColumn('video_url', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品视频'])
->addColumn('is_sale', 'boolean', ['default' => 1, 'null' => false, 'comment' => '是否在售:1是,0否'])
->addColumn('is_new', 'boolean', ['default' => 0, 'null' => false, 'comment' => '是否新品:1新品,0非新品'])
->addColumn('is_hot', 'boolean', ['default' => 0, 'null' => false, 'comment' => '是否热销:1热销,0非热销'])
->addColumn('is_show', 'boolean', ['default' => 0, 'null' => false, 'comment' => '是否上架:1上架,0下架'])
->addColumn('stock_qty', 'integer', ['signed' => false, 'null' => true, 'default' => 0, 'comment' => '库存数量'])
->addColumn('sort', 'integer', ['null' => false, 'default' => 0, 'comment' => '排序'])
->addColumn('detail', 'text', ['null' => true, 'comment' => '产品详情'])
->addColumn('status', 'boolean', ['null' => false, 'default' => 1, 'comment' => '状态:1启用,-1禁用'])
->addColumn('seo_title', 'string', ['limit' => 255, 'default' => null, 'comment' => 'seo标题'])
->addColumn('seo_keywords', 'string', ['limit' => 255, 'default' => null, 'comment' => 'seo关建词'])
->addColumn('seo_desc', 'string', ['limit' => 512, 'default' => null, 'comment' => 'seo描述'])
->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();
}
}