<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250516080900 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create table for analytics data from creator app screenshots';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE analytics_creators_data (id BIGINT UNSIGNED NOT NULL, subscribers JSON NOT NULL, viewers JSON NOT NULL, genders_by_subscribers JSON NOT NULL, genders_by_viewers JSON NOT NULL, ages_by_subscribers JSON NOT NULL, ages_by_viewers JSON NOT NULL, locations_by_subscribers JSON NOT NULL, locations_by_viewers JSON NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE analytics_creators_data ADD CONSTRAINT FK_67A87C49BF396750 FOREIGN KEY (id) REFERENCES creator (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE analytics_creators_data DROP FOREIGN KEY FK_67A87C49BF396750');
$this->addSql('DROP TABLE analytics_creators_data');
}
}