-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3664 from MTES-MCT/feature/3650-timestampable-on-…
…zone [TECH] Ajout du trait TimestampableTrait sur la table zone
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20250204095010 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add created_at and updated_at fields on Zone'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE zone ADD created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD updated_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE type type VARCHAR(255) NOT NULL COMMENT \'Value possible enum ZoneType\''); | ||
$this->addSql(" | ||
UPDATE zone z | ||
INNER JOIN history_entry h ON z.id = h.entity_id | ||
SET z.created_at = h.created_at | ||
WHERE h.entity_name LIKE '%Zone' | ||
AND h.event LIKE 'CREATE' | ||
"); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE zone DROP created_at, DROP updated_at, CHANGE type type VARCHAR(255) DEFAULT \'AUTRE\' NOT NULL COMMENT \'Value possible enum ZoneType\''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters