M230621080751QimallVideoTutorialsLog.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230621080751QimallVideoTutorialsLog
  6. */
  7. class M230621080751QimallVideoTutorialsLog extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_video_tutorials_log';
  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_video_tutorials_log` (
  21. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  22. `admin_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '账户id',
  23. `video_tutorials_id` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '视频教程id',
  24. `is_complete` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否完整观看;1:是;0否',
  25. `view_times` int(11) NOT NULL DEFAULT '0' COMMENT '浏览时长',
  26. `created_at` int(11) NOT NULL DEFAULT '0',
  27. `updated_at` int(11) NOT NULL DEFAULT '0',
  28. `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  29. PRIMARY KEY (`id`) USING BTREE
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='视频教程浏览记录';
  31. ";
  32. $this->execute($sql);
  33. }catch (\Exception $e){
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M230621080751QimallVideoTutorialsLog cannot be reverted.\n";
  42. return false;
  43. }
  44. /*
  45. // Use up()/down() to run migration code without a transaction.
  46. public function up()
  47. {
  48. }
  49. public function down()
  50. {
  51. echo "M230621080751QimallVideoTutorialsLog cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }