diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 25138b9..f60e85b 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -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 diff --git a/migrations/Version20250907153515.php b/migrations/Version20250907153515.php new file mode 100644 index 0000000..2128921 --- /dev/null +++ b/migrations/Version20250907153515.php @@ -0,0 +1,46 @@ +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'); + } +} diff --git a/migrations/Version20250907153958.php b/migrations/Version20250907153958.php new file mode 100644 index 0000000..476e4ca --- /dev/null +++ b/migrations/Version20250907153958.php @@ -0,0 +1,49 @@ +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'); + } +}