migrations/Version20220718141904.php line 1

Open in your IDE?
  1. <?php
  2. /* @noinspection PhpUnused */
  3. declare(strict_types=1);
  4. namespace DoctrineMigrations;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  *
  10.  * @package API
  11.  * @internal
  12.  */
  13. final class Version20220718141904 extends AbstractMigration
  14. {
  15.     public function down(Schema $schema): void
  16.     {
  17.         // this down() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6498C03F15C');
  19.         $this->addSql('DROP TABLE user');
  20.     }
  21.     public function getDescription(): string
  22.     {
  23.         return
  24.             "Introduces user table.";
  25.     }
  26.     public function up(Schema $schema): void
  27.     {
  28.         // this up() migration is auto-generated, please modify it to your needs
  29.         $this->addSql(
  30.             '
  31.                 CREATE TABLE user (
  32.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  33.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  34.                     username VARCHAR(100) NOT NULL COMMENT \'Unique username (identifier)\',
  35.                     password VARCHAR(255) NOT NULL COMMENT \'Hashed password\',
  36.                     email VARCHAR(254) NOT NULL COMMENT \'E-mail address\',
  37.                     first_name VARCHAR(225) NOT NULL COMMENT \'First name\',
  38.                     last_name VARCHAR(225) NOT NULL COMMENT \'Last name\',
  39.                     options JSON DEFAULT NULL COMMENT \'User configuration\',
  40.                     manual_user SMALLINT DEFAULT 1 NOT NULL COMMENT \'Flag for manually created users\',
  41.                     new_password_needed SMALLINT DEFAULT 1 NOT NULL COMMENT
  42.                         \'Flag if user must override his temporary password with a new one\',
  43.                     last_login INT DEFAULT NULL COMMENT \'Last login date for user as UNIX timestamp\',
  44.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  45.                     employee_id INT DEFAULT NULL COMMENT \'Internal ID\',
  46.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  47.                     UNIQUE INDEX UNIQ_8D93D649F85E0677 (username),
  48.                     UNIQUE INDEX UNIQ_8D93D6498C03F15C (employee_id),
  49.                     PRIMARY KEY(id)
  50.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  51.             '
  52.         );
  53.         $this->addSql(
  54.             '
  55.                 ALTER TABLE user ADD CONSTRAINT FK_8D93D6498C03F15C FOREIGN KEY
  56.                     (employee_id) REFERENCES employee (id)
  57.             '
  58.         );
  59.     }
  60. }