50 lines
2.3 KiB
PHP
50 lines
2.3 KiB
PHP
<?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');
|
|
}
|
|
}
|