M210909083847InsertQimallGlobalVarMap.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. *
  6. * Class M220909073847CreateQimallGlobalVarMap
  7. */
  8. class M210909083847InsertQimallGlobalVarMap extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $table = 'qimall_global_var_map';
  17. $check_table_sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  18. $res = $this->db->createCommand($check_table_sql)->execute();
  19. if(!empty($res)) return '';
  20. // 插入表数据
  21. $sql="INSERT INTO `qimall_global_var_map`( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ( 'extra_equal_1', '平一级奖励', 'CapitalTypeMap', 0, 1, 1661841988, 1661841988);";
  22. $this->execute($sql);
  23. $sql="INSERT INTO `qimall_global_var_map`( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ( 'extra_equal_2', '平二级奖励', 'CapitalTypeMap', 0, 1, 1661841988, 1661841988);";
  24. $this->execute($sql);
  25. $sql="INSERT INTO `qimall_global_var_map`( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('drainage_subsidy', '引流补贴', 'CapitalTypeMap', 0, 1, 1661841988, 1661841988)";
  26. $this->execute($sql);
  27. $sql="INSERT INTO `qimall_global_var_map`( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ( 'team_subsidy', '团队补贴', 'CapitalTypeMap', 0, 1, 1661841988, 1661841988);";
  28. $this->execute($sql);
  29. }catch (\Exception $e){
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function safeDown()
  36. {
  37. echo "M220909073847CreateQimallGlobalVarMap 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 "M220909073847CreateQimallGlobalVarMap cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }