20221112115300_update_ticket.php 959 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. final class UpdateTicket extends AbstractMigration
  5. {
  6. public function up(): void
  7. {
  8. if ($this->table('ticket')->hasColumn('rootid')) {
  9. $this->table('ticket')
  10. ->changeColumn('content', 'json', [ 'comment' => '工单内容', 'default' => '' ])
  11. ->changeColumn('status', 'string', [ 'comment' => '工单状态', 'default' => '' ])
  12. ->addColumn('type', 'string', [ 'comment' => '工单类型', 'default' => 'other' ])
  13. ->removeColumn('rootid')
  14. ->save();
  15. }
  16. }
  17. public function down(): void
  18. {
  19. $this->table('ticket')
  20. ->changeColumn->addColumn('content', 'text', [])
  21. ->changeColumn('status', 'integer', [ 'default' => 1 ])
  22. ->removeColumn('type')
  23. ->addColumn('rootid', 'biginteger', [])
  24. ->save();
  25. }
  26. }