<?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 Version20250329200502 extends AbstractMigration
{
// shared-sales-stats
public const WIDGET_ID_1 = 36;
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(sprintf('INSERT INTO widget (id, token, name, category, enabled) VALUES (%d, \'shared-sales-stats\', \'Sales Stats\', \'Shared\', 1)', self::WIDGET_ID_1));
$users = $this->connection->fetchAllAssociative('SELECT id FROM user');
foreach ($users as $user) {
$this->addSql('INSERT INTO user_widget (object_id, widget_id) VALUES (?, ?)', [$user['id'], self::WIDGET_ID_1]);
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(sprintf('DELETE FROM widget WHERE id = %d', self::WIDGET_ID_1));
$this->addSql(sprintf('DELETE FROM user_widget WHERE widget_id = %d', self::WIDGET_ID_1));
}
}