migrations/Identity/Version20200227100457_UserPassword.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Identity;
  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 Version20200227100457_UserPassword extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Create password table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("CREATE TABLE user_password (
  18.             id                  SERIAL PRIMARY KEY,
  19.             user_id             INTEGER                     NOT NULL REFERENCES public.user (id),
  20.             value               CHARACTER VARYING           NOT NULL,
  21.             expired             BOOLEAN                              DEFAULT FALSE,
  22.             created_by          INTEGER                              REFERENCES public.user (id),
  23.             updated_by          INTEGER                              REFERENCES public.user (id),
  24.             created_at          TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  25.             updated_at          TIMESTAMP(0) WITH TIME ZONE,
  26.             deleted_at          TIMESTAMP(0) WITH TIME ZONE,
  27.             CONSTRAINT user_password_user_value_key UNIQUE (user_id, value)
  28.         )");
  29.         $this->addSql("CREATE INDEX user_password_user_id_idx ON user_password (user_id)");
  30.         $this->addSql("CREATE INDEX user_password_created_by_idx ON user_password (created_by)");
  31.         $this->addSql("CREATE INDEX user_password_updated_by_idx ON user_password (updated_by)");
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         $this->addSql("DROP TABLE IF EXISTS user_password");
  36.     }
  37. }