You've already forked symfony-playground
dates
This commit is contained in:
47
migrations/Version20220523132530.php
Normal file
47
migrations/Version20220523132530.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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 Version20220523132530 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// MODIFICATION NEEDED: added DATETIME() to INSERTS to prevent:
|
||||
// SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: mer_para_sub.sub_date
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP INDEX IDX_E4F82A3DED5CA9E6');
|
||||
$this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, red_code FROM mer_para_sub');
|
||||
$this->addSql('DROP TABLE mer_para_sub');
|
||||
$this->addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, red_code VARCHAR(255) DEFAULT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable)
|
||||
, unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable)
|
||||
, CONSTRAINT FK_E4F82A3DED5CA9E6 FOREIGN KEY (service_id) REFERENCES mer_service (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||
$this->addSql('INSERT INTO mer_para_sub (id, service_id, red_code, sub_date) SELECT id, service_id, red_code, DATETIME() FROM __temp__mer_para_sub');
|
||||
$this->addSql('DROP TABLE __temp__mer_para_sub');
|
||||
$this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP INDEX IDX_E4F82A3DED5CA9E6');
|
||||
$this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, red_code FROM mer_para_sub');
|
||||
$this->addSql('DROP TABLE mer_para_sub');
|
||||
$this->addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, red_code VARCHAR(255) DEFAULT NULL)');
|
||||
$this->addSql('INSERT INTO mer_para_sub (id, service_id, red_code) SELECT id, service_id, red_code FROM __temp__mer_para_sub');
|
||||
$this->addSql('DROP TABLE __temp__mer_para_sub');
|
||||
$this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user