| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230620061317QimallAdminAddonsViews
- */
- class M230620061317QimallAdminAddonsViews extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_admin_addons_views';
- $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if(!empty($res)) return '';
- $sql="
- CREATE TABLE `qimall_admin_addons_views` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `admin_id` int(11) unsigned NOT NULL default 0 comment '账户id',
- `addons` varchar(255) NOT NULL DEFAULT '' comment '应用名称',
- `view_times` int(11) not null default 0 comment '浏览时长',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB COMMENT='应用浏览时长';
- ";
- $this->execute($sql);
- }catch (\Exception $e){
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230620061317QimallAdminAddonsViews cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230620061317QimallAdminAddonsViews cannot be reverted.\n";
- return false;
- }
- */
- }
|