<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221129130148 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("INSERT INTO `std_roles` (`id`, `created_by`, `updated_by`, `name`, `created_date`, `updated_date`) VALUES (1, 1, 1, 'ROLE_SUPER_ADMIN', now(), now());");
//get id of ROLE_SUPER_ADMIN
$this->addSql("set @idsuper=(SELECT id FROM `std_users` WHERE username = 'superadmin' and is_active=1 and is_deleted=0);");
$this->addSql("insert into std_users_roles(role_id,user_id,created_by,updated_by,created_date,updated_date) SELECT id,@idsuper,@idsuper,@idsuper,now(),now() FROM `std_roles` WHERE name = 'ROLE_SUPER_ADMIN';");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("DELETE FROM `std_users_roles` WHERE role_id = (SELECT id FROM `std_roles` WHERE name = 'ROLE_SUPER_ADMIN');");
$this->addSql("DELETE FROM `std_roles` WHERE name = 'ROLE_SUPER_ADMIN';");
}
}