mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 02:09:03 +02:00
Added an database migration to improve the log schema.
This commit is contained in:
parent
3178dcbb6c
commit
d5f018a738
3 changed files with 45 additions and 2 deletions
|
@ -12,7 +12,7 @@ doctrine:
|
||||||
date:
|
date:
|
||||||
class: App\Helpers\UTCDateTimeType
|
class: App\Helpers\UTCDateTimeType
|
||||||
|
|
||||||
schema_filter: ~^(?!internal|log)~
|
schema_filter: ~^(?!internal)~
|
||||||
profiling_collect_backtrace: true
|
profiling_collect_backtrace: true
|
||||||
|
|
||||||
orm:
|
orm:
|
||||||
|
|
|
@ -115,7 +115,7 @@ abstract class AbstractLogEntry extends DBElement
|
||||||
|
|
||||||
/** @var User $user The user which has caused this log entry
|
/** @var User $user The user which has caused this log entry
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
||||||
* @ORM\JoinColumn(name="id_user")
|
* @ORM\JoinColumn(name="id_user", nullable=false)
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
|
43
src/Migrations/Version20200126191823.php
Normal file
43
src/Migrations/Version20200126191823.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?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 Version20200126191823 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return 'Improve the schema of the log table';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE log CHANGE datetime datetime DATETIME NOT NULL, CHANGE level level TINYINT, CHANGE extra extra LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\'');
|
||||||
|
$this->addSql('DROP INDEX id_user ON log');
|
||||||
|
$this->addSql('ALTER TABLE log ADD CONSTRAINT FK_8F3F68C56B3CA4B FOREIGN KEY (id_user) REFERENCES `users` (id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_8F3F68C56B3CA4B ON log (id_user)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE log DROP FOREIGN KEY FK_8F3F68C56B3CA4B');
|
||||||
|
$this->addSql('ALTER TABLE log DROP FOREIGN KEY FK_8F3F68C56B3CA4B');
|
||||||
|
$this->addSql('ALTER TABLE log CHANGE datetime datetime DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, CHANGE level level TINYINT(1) NOT NULL, CHANGE extra extra MEDIUMTEXT CHARACTER SET utf8 NOT NULL COLLATE `utf8_general_ci`');
|
||||||
|
$this->addSql('DROP INDEX idx_8f3f68c56b3ca4b ON log');
|
||||||
|
$this->addSql('CREATE INDEX id_user ON log (id_user)');
|
||||||
|
$this->addSql('ALTER TABLE log ADD CONSTRAINT FK_8F3F68C56B3CA4B FOREIGN KEY (id_user) REFERENCES `users` (id)');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue