<?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 Version20240610115931 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('CREATE SEQUENCE content_source_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE content_source (id INT NOT NULL, base_url VARCHAR(255) NOT NULL, image_selector VARCHAR(255) DEFAULT NULL, next_page_selector VARCHAR(255) DEFAULT NULL, chapter_url_format VARCHAR(255) NOT NULL, scraping_type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('ALTER TABLE chapter ADD volume INT DEFAULT NULL');
        $this->addSql('ALTER TABLE chapter ADD title VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE chapter ADD local_path VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE manga ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL');
        $this->addSql('ALTER TABLE manga ADD rating DOUBLE PRECISION DEFAULT NULL');
        $this->addSql('ALTER TABLE manga ADD author VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE manga ADD external_id VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE manga ADD status VARCHAR(255) DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN manga.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_765A9E03989D9B62 ON manga (slug)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('DROP SEQUENCE content_source_id_seq CASCADE');
        $this->addSql('DROP TABLE content_source');
        $this->addSql('DROP INDEX UNIQ_765A9E03989D9B62');
        $this->addSql('ALTER TABLE manga DROP created_at');
        $this->addSql('ALTER TABLE manga DROP rating');
        $this->addSql('ALTER TABLE manga DROP author');
        $this->addSql('ALTER TABLE manga DROP external_id');
        $this->addSql('ALTER TABLE manga DROP status');
        $this->addSql('ALTER TABLE chapter DROP volume');
        $this->addSql('ALTER TABLE chapter DROP title');
        $this->addSql('ALTER TABLE chapter DROP local_path');
    }
}
