Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Latest
* [#91](https://github.com/cleverage/ui-process-bundle/issues/91) `LoginController`: pass `error` and `last_username` (`AuthenticationUtils`) to the login template, so that a failed login displays the error message and keeps the email. Test updated.
* [#95](https://github.com/cleverage/ui-process-bundle/issues/95) `DoctrineProcessHandler`: detach the written `LogRecord` entities after each flush (the Monolog records were detached instead), so that the identity map no longer grows during long processes; `LogRecord::$processExecution` cascade reduced from `all` to `persist`, so that detaching a log record does not detach the current process execution (which would then be inserted again). Add tests.
* [#97](https://github.com/cleverage/ui-process-bundle/issues/97) Align the mapping and the schema created by the migrations: `ProcessSchedule::$input` mapped as `VARCHAR(255)` as created by the migrations (was `TEXT`); `Version20261005120000` migration (MySQL / MariaDB, PostgreSQL) making `log_record.process_execution_id` `NOT NULL` as in the mapping (log records without process execution are deleted).
* [#99](https://github.com/cleverage/ui-process-bundle/issues/99) Fix the migrations on PostgreSQL (they could not create a working schema): id columns created as identity columns (the sequences were not used: inserts failed with the IDENTITY generation), `process_schedule` created with the PostgreSQL syntax (`AUTO_INCREMENT` failed). PostgreSQL support documented.

v3.0.2
------
Expand Down
7 changes: 5 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ See [users & security](reference/03-users_and_security.md).

### Database

The bundle registers its own Doctrine migrations (`CleverAge\UiProcessBundle\Migrations`). Run them, then create a
first user:
Supported databases: **MySQL / MariaDB** and **PostgreSQL**.

The bundle registers its own Doctrine migrations (`CleverAge\UiProcessBundle\Migrations`), written for these two
platforms (on another platform, e.g. SQLite, they do nothing: create the schema with `doctrine:schema:update`). Run
them, then create a first user:

```bash
bin/console doctrine:migrations:migrate
Expand Down
9 changes: 3 additions & 6 deletions src/Migrations/Version20231006111525.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,22 @@ public function up(Schema $schema): void

if ($platform instanceof PostgreSQLPlatform) {
if (!$schema->hasTable('log_record')) {
$this->addSql('CREATE SEQUENCE log_record_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE log_record (id INT NOT NULL, process_execution_id INT DEFAULT NULL, channel VARCHAR(64) NOT NULL, level INT NOT NULL, message VARCHAR(512) NOT NULL, context JSON NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE log_record (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, process_execution_id INT DEFAULT NULL, channel VARCHAR(64) NOT NULL, level INT NOT NULL, message VARCHAR(512) NOT NULL, context JSON NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_8ECECC333DAC0075 ON log_record (process_execution_id)');
$this->addSql('CREATE INDEX idx_log_record_level ON log_record (level)');
$this->addSql('CREATE INDEX idx_log_record_created_at ON log_record (created_at)');
$this->addSql('COMMENT ON COLUMN log_record.created_at IS \'(DC2Type:datetime_immutable)\'');
}
if (!$schema->hasTable('process_execution')) {
$this->addSql('CREATE SEQUENCE process_execution_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE process_execution (id INT NOT NULL, code VARCHAR(255) NOT NULL, log_filename VARCHAR(255) NOT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, status VARCHAR(255) NOT NULL, report JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE process_execution (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, code VARCHAR(255) NOT NULL, log_filename VARCHAR(255) NOT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, status VARCHAR(255) NOT NULL, report JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX idx_process_execution_code ON process_execution (code)');
$this->addSql('CREATE INDEX idx_process_execution_start_date ON process_execution (start_date)');
$this->addSql('COMMENT ON COLUMN process_execution.start_date IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN process_execution.end_date IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE log_record ADD CONSTRAINT FK_8ECECC333DAC0075 FOREIGN KEY (process_execution_id) REFERENCES process_execution (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
if (!$schema->hasTable('process_user')) {
$this->addSql('CREATE SEQUENCE process_user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE process_user (id INT NOT NULL, email VARCHAR(255) NOT NULL, firstname VARCHAR(255) DEFAULT NULL, lastname VARCHAR(255) DEFAULT NULL, roles JSON NOT NULL, password VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE process_user (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, email VARCHAR(255) NOT NULL, firstname VARCHAR(255) DEFAULT NULL, lastname VARCHAR(255) DEFAULT NULL, roles JSON NOT NULL, password VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_627A047CE7927C74 ON process_user (email)');
$this->addSql('CREATE INDEX idx_process_user_email ON process_user (email)');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Migrations/Version20240729151928.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function up(Schema $schema): void
{
$platform = $this->connection->getDatabasePlatform();
if ($platform instanceof PostgreSQLPlatform) {
$this->addSql('CREATE TABLE process_schedule (id INT AUTO_INCREMENT NOT NULL, process VARCHAR(255) NOT NULL, type VARCHAR(6) NOT NULL, expression VARCHAR(255) NOT NULL, input VARCHAR(255), context JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE process_schedule (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, process VARCHAR(255) NOT NULL, type VARCHAR(6) NOT NULL, expression VARCHAR(255) NOT NULL, input VARCHAR(255) DEFAULT NULL, context JSON NOT NULL, PRIMARY KEY(id))');
}

if ($platform instanceof MariaDBPlatform || $platform instanceof MySQLPlatform) {
Expand Down
87 changes: 0 additions & 87 deletions tests/Migrations/MigrationTestCase.php

This file was deleted.

131 changes: 0 additions & 131 deletions tests/Migrations/Version20231006111525Test.php

This file was deleted.

72 changes: 0 additions & 72 deletions tests/Migrations/Version20240729151928Test.php

This file was deleted.

46 changes: 0 additions & 46 deletions tests/Migrations/Version20240730090403Test.php

This file was deleted.

Loading
Loading