migrations/Version20240219074039.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 Version20240219074039 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.         $entries = [
  19.             ['title' => 'Download''slug' => 'admin_user_ads_data_download''route' => 'user-ads-data/index/download/''group' => 'User Ads Data''desc' => 'description''status' => '1'],
  20.             ['title' => 'Download''slug' => 'admin_media_kit_permission''route' => 'media-kit/index/download/*''group' => 'Media Kit ''desc' => 'description''status' => '1'],
  21.             ['title' => 'Show Password''slug' => 'admin_media_kit_show_password''route' => 'media-kit/index/showPassword/*''group' => 'Media Kit ''desc' => 'description''status' => '1'],
  22.         ];
  23.         foreach ($entries as $entry) {
  24.             $existingEntry $this->connection->fetchAssociative(
  25.                 'SELECT * FROM permissions WHERE permission_slug = :slug',
  26.                 ['slug' => $entry['slug']]
  27.             );
  28.             if (!$existingEntry) {
  29.                 $this->addSql('INSERT INTO permissions (permission_title, permission_slug , permission_route,permission_group,permission_description,status,created_at) VALUES (:title, :slug, :route, :group,:desc,:status,CURRENT_TIMESTAMP)', [
  30.                     'title' => $entry['title'],
  31.                     'slug' => $entry['slug'],
  32.                     'route' => $entry['route'],
  33.                     'group' => $entry['group'],
  34.                     'desc' => $entry['desc'],
  35.                     'status' => 1,
  36.                 ]);
  37.             }
  38.         }
  39.         $this->addSql('UPDATE `permissions` SET `permission_slug` = "admin_resource_types_add" WHERE `permissions`.`permission_route` = "resource-types/index/add/"');
  40.         $this->addSql('UPDATE `permissions` SET `permission_slug` = "admin_resource_types_edit" WHERE `permissions`.`permission_route` = "resource-types/index/edit/"');
  41.         $this->addSql('UPDATE `permissions` SET `permission_slug` = "admin_resource_types_delete" WHERE `permissions`.`permission_route` = "resource-types/index/delete/"');
  42.         $this->addSql('UPDATE `permissions` SET `permission_slug` = "admin_rating_criteria_listing" WHERE `permissions`.`permission_route` = "rating-criteria"');
  43.     }
  44.     public function down(Schema $schema): void
  45.     {
  46.         // this down() migration is auto-generated, please modify it to your needs
  47.        
  48.     }
  49. }