migrations/Version20230312114756.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7. * Auto-generated Migration: Please modify to your needs!
  8. */
  9. final class Version20230312114756 extends AbstractMigration
  10. {
  11. public function getDescription(): string
  12. {
  13. return '';
  14. }
  15. public function up(Schema $schema): void
  16. {
  17. // this up() migration is auto-generated, please modify it to your needs
  18. $this->addSql('CREATE TABLE course (id INT AUTO_INCREMENT NOT NULL, delivery_id INT NOT NULL, course_status_id INT NOT NULL, delivery_man_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_169E6FB912136921 (delivery_id), INDEX IDX_169E6FB9E9564011 (course_status_id), INDEX IDX_169E6FB9FD128646 (delivery_man_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19. $this->addSql('CREATE TABLE tracking (id INT AUTO_INCREMENT NOT NULL, course_id INT NOT NULL, date DATETIME NOT NULL, latitude VARCHAR(255) NOT NULL, longitude VARCHAR(255) NOT NULL, INDEX IDX_A87C621C591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20. $this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB912136921 FOREIGN KEY (delivery_id) REFERENCES delivery (id)');
  21. $this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB9E9564011 FOREIGN KEY (course_status_id) REFERENCES course_status (id)');
  22. $this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB9FD128646 FOREIGN KEY (delivery_man_id) REFERENCES delivery_man (id)');
  23. $this->addSql('ALTER TABLE tracking ADD CONSTRAINT FK_A87C621C591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
  24. $this->addSql('ALTER TABLE authorized_naf ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
  25. $this->addSql('ALTER TABLE compliment ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
  26. $this->addSql('ALTER TABLE course_status ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
  27. $this->addSql('ALTER TABLE course_status RENAME INDEX idx_65119c929d419299 TO IDX_D538A4519D419299');
  28. $this->addSql('ALTER TABLE course_status RENAME INDEX idx_65119c92ac8de0f TO IDX_D538A451AC8DE0F');
  29. $this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_270c8ccd9d419299 TO IDX_65119C929D419299');
  30. $this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_270c8ccdac8de0f TO IDX_65119C92AC8DE0F');
  31. $this->addSql('ALTER TABLE rank_type ADD user_type_id INT DEFAULT NULL, CHANGE min min INT DEFAULT NULL, CHANGE max max INT DEFAULT NULL');
  32. $this->addSql('ALTER TABLE rank_type ADD CONSTRAINT FK_8A7E47D69D419299 FOREIGN KEY (user_type_id) REFERENCES user_type (id)');
  33. $this->addSql('CREATE INDEX IDX_8A7E47D69D419299 ON rank_type (user_type_id)');
  34. $this->addSql('ALTER TABLE stream_type ADD date_start DATETIME NOT NULL');
  35. $this->addSql("UPDATE stream_type set date_start='1900-01-01'");
  36. $this->addSql("UPDATE authorized_naf set date_start='1900-01-01'");
  37. $this->addSql("UPDATE compliment set date_start='1900-01-01'");
  38. $this->addSql("UPDATE course_status set date_start='1900-01-01'");
  39. }
  40. public function down(Schema $schema): void
  41. {
  42. // this down() migration is auto-generated, please modify it to your needs
  43. $this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB912136921');
  44. $this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB9E9564011');
  45. $this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB9FD128646');
  46. $this->addSql('ALTER TABLE tracking DROP FOREIGN KEY FK_A87C621C591CC992');
  47. $this->addSql('DROP TABLE course');
  48. $this->addSql('DROP TABLE tracking');
  49. $this->addSql('ALTER TABLE authorized_naf DROP date_start, DROP date_end');
  50. $this->addSql('ALTER TABLE compliment DROP date_start, DROP date_end');
  51. $this->addSql('ALTER TABLE course_status DROP date_start, DROP date_end');
  52. $this->addSql('ALTER TABLE course_status RENAME INDEX idx_d538a4519d419299 TO IDX_65119C929D419299');
  53. $this->addSql('ALTER TABLE course_status RENAME INDEX idx_d538a451ac8de0f TO IDX_65119C92AC8DE0F');
  54. $this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_65119c929d419299 TO IDX_270C8CCD9D419299');
  55. $this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_65119c92ac8de0f TO IDX_270C8CCDAC8DE0F');
  56. $this->addSql('ALTER TABLE rank_type DROP FOREIGN KEY FK_8A7E47D69D419299');
  57. $this->addSql('DROP INDEX IDX_8A7E47D69D419299 ON rank_type');
  58. $this->addSql('ALTER TABLE rank_type DROP user_type_id, CHANGE min min INT NOT NULL, CHANGE max max INT NOT NULL');
  59. $this->addSql('ALTER TABLE stream_type DROP date_start');
  60. }
  61. }