<?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 Version20251027232410 extends AbstractMigration
{
public function getDescription(): string
{
return 'Crea la tabla landing_page y header con relación OneToOne';
}
public function up(Schema $schema): void
{
// Crear tabla landing_page
$this->addSql('CREATE TABLE landing_page (
id INT AUTO_INCREMENT NOT NULL,
titulo VARCHAR(255) NOT NULL,
descripcion LONGTEXT DEFAULT NULL,
activo TINYINT(1) DEFAULT 1 NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
deleted_at DATETIME DEFAULT NULL,
INDEX IDX_TITULO (titulo),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
// Crear tabla header con relación a landing_page
$this->addSql('CREATE TABLE header (
id INT AUTO_INCREMENT NOT NULL,
landing_page_id INT DEFAULT NULL,
titulo VARCHAR(255) NOT NULL,
descripcion LONGTEXT DEFAULT NULL,
fondo VARCHAR(50) DEFAULT \'cyan\',
aside VARCHAR(50) DEFAULT \'bg-aside-hero-dark\',
multimedia VARCHAR(255) DEFAULT NULL,
url_gif VARCHAR(255) DEFAULT NULL,
url_video VARCHAR(255) DEFAULT NULL,
autoplay TINYINT(1) DEFAULT 0 NOT NULL,
video_loop TINYINT(1) DEFAULT 0 NOT NULL,
muted TINYINT(1) DEFAULT 0 NOT NULL,
video_controls TINYINT(1) DEFAULT 0 NOT NULL,
tipo_multimedia VARCHAR(50) DEFAULT \'imagen\',
tipo_diseno VARCHAR(50) DEFAULT \'corner\',
mostrar_multimedia TINYINT(1) DEFAULT 0 NOT NULL,
mostrar_botones TINYINT(1) DEFAULT 0 NOT NULL,
texto_boton_primario VARCHAR(100) DEFAULT NULL,
enlace_boton_primario VARCHAR(500) DEFAULT NULL,
texto_boton_secundario VARCHAR(100) DEFAULT NULL,
enlace_boton_secundario VARCHAR(500) DEFAULT NULL,
activo TINYINT(1) NOT NULL,
posicion INT DEFAULT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
deleted_at DATETIME DEFAULT NULL,
INDEX IDX_TITULO (titulo),
INDEX IDX_landing_page_id (landing_page_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
// Crear foreign key de header a landing_page
$this->addSql('ALTER TABLE header ADD CONSTRAINT FK_header_landing_page FOREIGN KEY (landing_page_id) REFERENCES landing_page (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
// Eliminar foreign key primero
$this->addSql('ALTER TABLE header DROP FOREIGN KEY FK_header_landing_page');
// Eliminar tablas
$this->addSql('DROP TABLE header');
$this->addSql('DROP TABLE landing_page');
}
}