20251015053004_notifications_template_context.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. final class NotificationsTemplateContext extends AbstractMigration
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
  13. *
  14. * Remember to call "create()" or "update()" and NOT "save()" when working
  15. * with the Table class.
  16. */
  17. public function up(): void
  18. {
  19. $table = $this->table('message_notifications');
  20. $table->addColumn('template_context', 'json', ['comment' => '模板上下文', 'after' => 'template_code'])
  21. ->removeColumn('template_content')
  22. ->update();
  23. }
  24. public function down(): void
  25. {
  26. $table = $this->table('message_notifications');
  27. $table->addColumn('template_content', 'text', ['comment' => '模板内容', 'after' => 'template_code'])
  28. ->removeColumn('template_context')
  29. ->update();
  30. }
  31. }