| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230216065345AddQimallServiceAgreement
- */
- class M230216065345AddQimallServiceAgreement extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_service_agreement';
- $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if (!empty($res)) return '';
- $sql = "
- CREATE TABLE `qimall_service_agreement` (
- `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',
- `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城id',
- `name` varchar(255) DEFAULT '' COMMENT '协议名称',
- `remark` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注',
- `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
- `content` longtext COMMENT '内容',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
- `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='服务协议表';
- ";
- $this->execute($sql);
- } catch (\Exception $e) {
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230216065345AddQimallServiceAgreement cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230216065345AddQimallServiceAgreement cannot be reverted.\n";
- return false;
- }
- */
- }
|