M230522104210AddTableGoodsSpecs.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230522104210AddTableGoodsSpecs
  6. */
  7. class M230522104210AddTableGoodsSpecs extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = "CREATE TABLE `qimall_goods_specs` (
  16. `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  17. `mall_id` int UNSIGNED NOT NULL COMMENT '商城ID',
  18. `store_id` int UNSIGNED NOT NULL COMMENT '店铺ID',
  19. `name` varchar(64) NOT NULL COMMENT '规格名称',
  20. `values` longtext NOT NULL COMMENT '规格值',
  21. `updated_at` int UNSIGNED NULL,
  22. `created_at` int UNSIGNED NULL,
  23. PRIMARY KEY (`id`)
  24. );";
  25. $this->execute($sql);
  26. } catch (\Exception $e) {
  27. }
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function safeDown()
  33. {
  34. echo "M230522104210AddTableGoodsSpecs cannot be reverted.\n";
  35. return false;
  36. }
  37. /*
  38. // Use up()/down() to run migration code without a transaction.
  39. public function up()
  40. {
  41. }
  42. public function down()
  43. {
  44. echo "M230228081131InsertQimallMenu cannot be reverted.\n";
  45. return false;
  46. }
  47. */
  48. }