M230218073410CreateQimallCommissionLogRelation.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230218073410CreateQimallCommissionLogRelation
  6. */
  7. class M230218073410CreateQimallCommissionLogRelation extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_commission_log_relation';
  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="CREATE TABLE `qimall_commission_log_relation` (
  20. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  21. `log_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'commisssion的id/commisssion的id_frozen的id',
  22. `source_type` varchar(255) NOT NULL DEFAULT '' COMMENT 'commisssion/commisssion_frozen',
  23. `describe` varchar(1000) NOT NULL DEFAULT '' COMMENT '自定义的描述',
  24. `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间戳',
  25. PRIMARY KEY (`id`) USING BTREE,
  26. KEY `idx_source_type_log_id` (`source_type`,`log_id`) USING BTREE
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='佣金记录关联表表';";
  28. $this->execute($sql);
  29. }catch (\Exception $e){
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function safeDown()
  36. {
  37. echo "M230218073410CreateQimallCommissionLogRelation cannot be reverted.\n";
  38. return false;
  39. }
  40. /*
  41. // Use up()/down() to run migration code without a transaction.
  42. public function up()
  43. {
  44. }
  45. public function down()
  46. {
  47. echo "M230218073410CreateQimallCommissionLogRelation cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }