m230405_032449_comments.php 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m230405_032449_comments
  5. */
  6. class m230405_032449_comments extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $sql = "ALTER TABLE `comments` ADD `parent_id` INT UNSIGNED NULL DEFAULT NULL AFTER `created_at`, ADD `likeed` INT NOT NULL DEFAULT '0' AFTER `parent_id`, ADD `fakename` VARCHAR(64) NULL DEFAULT NULL AFTER `likeed`, ADD INDEX `parent` (`parent_id`); COMMIT;";
  14. $this->execute($sql);
  15. }
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function safeDown()
  20. {
  21. echo "m230405_032449_comments cannot be reverted.\n";
  22. return false;
  23. }
  24. /*
  25. // Use up()/down() to run migration code without a transaction.
  26. public function up()
  27. {
  28. }
  29. public function down()
  30. {
  31. echo "m230405_032449_comments cannot be reverted.\n";
  32. return false;
  33. }
  34. */
  35. }