m230214_035736_comments_conf.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m230214_035736_comments_conf
  5. */
  6. class m230214_035736_comments_conf extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $sql = "CREATE TABLE `comments_conf` (
  14. `AllStop` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  15. `reg` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  16. `dt_start` time NOT NULL DEFAULT '00:00:00',
  17. `dt_stop` time NOT NULL DEFAULT '23:59:59',
  18. `d0` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  19. `d1` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  20. `d2` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  21. `d3` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  22. `d4` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  23. `d5` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N',
  24. `d6` enum('N','Y') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N'
  25. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Настройка коментариев';
  26. COMMIT;";
  27. $this->execute($sql);
  28. $sql = "INSERT INTO `comments_conf` (`AllStop`, `reg`, `dt_start`, `dt_stop`, `d0`, `d1`, `d2`, `d3`, `d4`, `d5`, `d6`) VALUES ('N', 'N', '00:00:00.000000', '23:59:59.000000', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y');";
  29. $this->execute($sql);
  30. $sql = "ALTER TABLE `comments_conf` ADD `id` TINYINT NOT NULL DEFAULT '0' FIRST, ADD PRIMARY KEY (`id`);";
  31. $this->execute($sql);
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function safeDown()
  37. {
  38. echo "m230214_035736_comments_conf cannot be reverted.\n";
  39. return false;
  40. }
  41. /*
  42. // Use up()/down() to run migration code without a transaction.
  43. public function up()
  44. {
  45. }
  46. public function down()
  47. {
  48. echo "m230214_035736_comments_conf cannot be reverted.\n";
  49. return false;
  50. }
  51. */
  52. }