<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use App\Migration\AbstractMultiPlatformMigration;
use Doctrine\DBAL\Schema\Schema;

final class Version20250706201121 extends AbstractMultiPlatformMigration
{
    public function getDescription(): string
    {
        return 'Add settings_entry table for storing settings';
    }

    public function mySQLUp(Schema $schema): void
    {
        $this->addSql('CREATE TABLE settings_entry (`key` VARCHAR(255) NOT NULL, `data` JSON DEFAULT NULL, id INT AUTO_INCREMENT NOT NULL, UNIQUE INDEX UNIQ_93F8DB394E645A7E (`key`), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');

    }

    public function mySQLDown(Schema $schema): void
    {
        $this->addSql('DROP TABLE settings_entry');
    }

    public function sqLiteUp(Schema $schema): void
    {
        $this->addSql('CREATE TABLE settings_entry ("key" VARCHAR(255) NOT NULL, "data" CLOB DEFAULT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_93F8DB39F48571EB ON settings_entry ("key")');
    }

    public function sqLiteDown(Schema $schema): void
    {
        $this->addSql('DROP TABLE settings_entry');
    }

    public function postgreSQLUp(Schema $schema): void
    {
        $this->addSql('CREATE TABLE settings_entry ("key" VARCHAR(255) NOT NULL, "data" JSON DEFAULT NULL, id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_93F8DB39F48571EB ON settings_entry ("key")');
    }

    public function postgreSQLDown(Schema $schema): void
    {
        $this->addSql('DROP TABLE settings_entry');
    }
}
