migrations/Version20221101065407.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 Version20221101065407 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Создание таблицы глобальных настроек';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $settings = [
  18.             ['name' => 'TimeAmountForSalary''value' => '0''description' => 'Количество часов отработанного времени, относящегося к окладу'],
  19.             ['name' => 'TimeEntry.MaxDateEditingPeriod''value' => '2''description' => 'Максимальная глубина в днях от текущей даты, на которую можно редактировать ТЕ'],
  20.         ];
  21.         // this up() migration is auto-generated, please modify it to your needs
  22.         $this->addSql('CREATE SEQUENCE setting_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  23.         $this->addSql('CREATE TABLE setting (id INT NOT NULL, hub_user_id UUID DEFAULT NULL, name VARCHAR(50) NOT NULL, value VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT \'now()\' NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
  24.         $this->addSql('CREATE INDEX IDX_9F74B8985561CCEE ON setting (hub_user_id)');
  25.         $this->addSql('CREATE INDEX idx_setting_name ON setting (name)');
  26.         $this->addSql('COMMENT ON COLUMN setting.hub_user_id IS \'(DC2Type:uuid)\'');
  27.         $this->addSql('COMMENT ON COLUMN setting.name IS \'Name of Properties\'');
  28.         $this->addSql('COMMENT ON COLUMN setting.value IS \'Value of Properties\'');
  29.         $this->addSql('COMMENT ON COLUMN setting.description IS \'Description of Properties\'');
  30.         $this->addSql('COMMENT ON COLUMN setting.created_at IS \'Дата создания\'');
  31.         $this->addSql('COMMENT ON COLUMN setting.updated_at IS \'Дата обновления\'');
  32.         foreach ($settings as $setting) {
  33.             $this->addSql('INSERT INTO setting ("id", "name","value","description") VALUES ((select nextval(\'setting_id_seq\')), :name, :value ,:description) ON CONFLICT DO NOTHING'$setting);
  34.         }
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         // this down() migration is auto-generated, please modify it to your needs
  39.         $this->addSql('DROP SEQUENCE setting_id_seq CASCADE');
  40.         $this->addSql('DROP TABLE setting');
  41.     }
  42. }