M230620061317QimallAdminAddonsViews.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230620061317QimallAdminAddonsViews
  6. */
  7. class M230620061317QimallAdminAddonsViews extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_admin_addons_views';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $sql="
  20. CREATE TABLE `qimall_admin_addons_views` (
  21. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  22. `admin_id` int(11) unsigned NOT NULL default 0 comment '账户id',
  23. `addons` varchar(255) NOT NULL DEFAULT '' comment '应用名称',
  24. `view_times` int(11) not null default 0 comment '浏览时长',
  25. `created_at` int(11) NOT NULL DEFAULT '0',
  26. `updated_at` int(11) NOT NULL DEFAULT '0',
  27. `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  28. PRIMARY KEY (`id`) USING BTREE
  29. ) ENGINE=InnoDB COMMENT='应用浏览时长';
  30. ";
  31. $this->execute($sql);
  32. }catch (\Exception $e){
  33. }
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function safeDown()
  39. {
  40. echo "M230620061317QimallAdminAddonsViews cannot be reverted.\n";
  41. return false;
  42. }
  43. /*
  44. // Use up()/down() to run migration code without a transaction.
  45. public function up()
  46. {
  47. }
  48. public function down()
  49. {
  50. echo "M230620061317QimallAdminAddonsViews cannot be reverted.\n";
  51. return false;
  52. }
  53. */
  54. }