bug fix in updater
Some checks are pending
PHP Composer / build (push) Waiting to run

This commit is contained in:
Hesabix 2025-09-07 19:21:12 +03:30
parent a8409f2bbe
commit 0135a3da81
3 changed files with 97 additions and 0 deletions

View file

@ -8,6 +8,8 @@ doctrine:
profiling_collect_backtrace: '%kernel.debug%'
use_savepoints: true
options:
1002: "SET sql_mode = ''"
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true

View file

@ -0,0 +1,46 @@
<?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 Version20250907153515 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
// Temporarily disable strict mode to handle invalid datetime values
$this->addSql("SET sql_mode = ''");
// Fix invalid datetime values in all tables
$this->addSql("UPDATE answer SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$this->addSql("UPDATE answer_vote SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$this->addSql("UPDATE question SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$this->addSql("UPDATE question_vote SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$this->addSql("UPDATE wallets SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
// Re-enable strict mode
$this->addSql("SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO'");
// Add new columns to user table
$this->addSql('ALTER TABLE user ADD phone VARCHAR(20) DEFAULT NULL, ADD is_active TINYINT(1) NOT NULL, ADD email_verified_at DATETIME DEFAULT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME DEFAULT NULL, ADD last_login_at DATETIME DEFAULT NULL, ADD subscription_type VARCHAR(50) DEFAULT NULL, ADD subscription_expires_at DATETIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `user` DROP phone, DROP is_active, DROP email_verified_at, DROP created_at, DROP updated_at, DROP last_login_at, DROP subscription_type, DROP subscription_expires_at');
}
}

View file

@ -0,0 +1,49 @@
<?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 Version20250907153958 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
// Fix invalid datetime values by using raw SQL with connection
$connection = $this->connection;
// Temporarily disable strict mode
$connection->executeStatement("SET sql_mode = ''");
// Fix invalid datetime values in all tables
$connection->executeStatement("UPDATE answer SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$connection->executeStatement("UPDATE answer_vote SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$connection->executeStatement("UPDATE question SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$connection->executeStatement("UPDATE question_vote SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
$connection->executeStatement("UPDATE wallets SET created_at = NULL WHERE created_at = '0000-00-00 00:00:00'");
// Re-enable strict mode
$connection->executeStatement("SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO'");
// Add new columns to user table
$this->addSql('ALTER TABLE user ADD phone VARCHAR(20) DEFAULT NULL, ADD is_active TINYINT(1) NOT NULL, ADD email_verified_at DATETIME DEFAULT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME DEFAULT NULL, ADD last_login_at DATETIME DEFAULT NULL, ADD subscription_type VARCHAR(50) DEFAULT NULL, ADD subscription_expires_at DATETIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `user` DROP phone, DROP is_active, DROP email_verified_at, DROP created_at, DROP updated_at, DROP last_login_at, DROP subscription_type, DROP subscription_expires_at');
}
}