diff --git a/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php new file mode 100644 index 000000000..b4f4c63ba --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php @@ -0,0 +1,93 @@ + ''])] + private string $exportAlias, + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])] + private array $options = [], + #[ORM\Column(type: 'datetime_immutable', nullable: true)] + private ?\DateTimeImmutable $deleteAt = null, + ) { + $this->id = Uuid::uuid4(); + $this->storedObject = new StoredObject(StoredObject::STATUS_PENDING); + } + + public function setDeleteAt(?\DateTimeImmutable $deleteAt): ExportGeneration + { + $this->deleteAt = $deleteAt; + + return $this; + } + + public function getDeleteAt(): ?\DateTimeImmutable + { + return $this->deleteAt; + } + + public function getId(): UuidInterface + { + return $this->id; + } + + public function getStoredObject(): StoredObject + { + return $this->storedObject; + } + + public function getExportAlias(): string + { + return $this->exportAlias; + } + + public function getOptions(): array + { + return $this->options; + } + + public static function fromSavedExport(SavedExport $savedExport, null|\DateTimeImmutable $deletedAt = null): self + { + return new self($savedExport->getExportAlias(), $savedExport->getOptions(), $deletedAt); + } +} diff --git a/src/Bundle/ChillMainBundle/migrations/Version20250219130532.php b/src/Bundle/ChillMainBundle/migrations/Version20250219130532.php new file mode 100644 index 000000000..140254acc --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20250219130532.php @@ -0,0 +1,40 @@ +addSql('CREATE TABLE chill_main_export_generation (id UUID NOT NULL, deleteAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, exportAlias TEXT DEFAULT \'\' NOT NULL, options JSON DEFAULT \'[]\' NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, storedObject_id INT NOT NULL, createdBy_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_E644B77D6C99C13A ON chill_main_export_generation (storedObject_id)'); + $this->addSql('CREATE INDEX IDX_E644B77D3174800F ON chill_main_export_generation (createdBy_id)'); + $this->addSql('COMMENT ON COLUMN chill_main_export_generation.id IS \'(DC2Type:uuid)\''); + $this->addSql('COMMENT ON COLUMN chill_main_export_generation.deleteAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_export_generation.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE chill_main_export_generation ADD CONSTRAINT FK_E644B77D6C99C13A FOREIGN KEY (storedObject_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_main_export_generation ADD CONSTRAINT FK_E644B77D3174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_main_export_generation'); + } +}