Entity Website : - customer (ManyToOne, CASCADE) : client propriétaire - name : nom du site - uuid : UUID v4 auto-généré (unique, 36 chars) - type : vitrine | ecommerce - state : created → install_progress → open → suspended → closed - createdAt / updatedAt (auto sur setState) - isOpen() : vérifie si state === open WebsiteTest (5 tests, 20 assertions) : - testConstructor : valeurs par défaut, uuid 36 chars, type vitrine - testConstructorEcommerce : type ecommerce - testSetters : name, type, updatedAt - testState : transitions created→install_progress→open→suspended→closed - testUuidUnique : 2 sites ont des uuid différents Dépendance : symfony/uid ajouté pour Uuid::v4() Migration : CREATE TABLE website avec FK customer, uuid unique Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?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 Version20260404190626 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 TABLE website (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(255) NOT NULL, uuid VARCHAR(36) NOT NULL, type VARCHAR(20) NOT NULL, state VARCHAR(20) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, customer_id INT NOT NULL, PRIMARY KEY (id))');
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_476F5DE7D17F50A6 ON website (uuid)');
|
|
$this->addSql('CREATE INDEX IDX_476F5DE79395C3F3 ON website (customer_id)');
|
|
$this->addSql('ALTER TABLE website ADD CONSTRAINT FK_476F5DE79395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE NOT DEFERRABLE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE website DROP CONSTRAINT FK_476F5DE79395C3F3');
|
|
$this->addSql('DROP TABLE website');
|
|
}
|
|
}
|