SymfonyCasts/reset-password-bundle

Null Error during migration step

manzwebdesigns opened this issue · 3 comments

I tried to implement this and got this error. When I tried to rerun it, it says that the table already exists... see attached image.
Capture

Hey @manzwebdesigns!

What does the contents of that migration file look like? I'm curious which "Null value" it might be complaining about.

Cheers!

<?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 Version20221201193618 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
        $this->addSql('CREATE TABLE reset_password_request (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', expires_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_7CE748AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
        $this->addSql('ALTER TABLE `groups` CHANGE notes notes LONGTEXT NOT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE reset_password_request DROP FOREIGN KEY FK_7CE748AA76ED395');
        $this->addSql('DROP TABLE reset_password_request');
        $this->addSql('ALTER TABLE `groups` CHANGE notes notes LONGTEXT DEFAULT NULL');
    }
}

I think the error may be caused by this line:

$this->addSql('ALTER TABLE `groups` CHANGE notes notes LONGTEXT NOT NULL');

This is coming from somewhere in your code, not from reset-password-bundle. I'm pretty sure it's this line because, according to your screenshot, the first line that creates the table WAS successful. And the second line doesn't have any mentions of null. So that leaves this third line. I'm not sure why NULL is a problem there, but it looks like something custom from your project :).

Cheers!