Think-migration failed to create table

problem description

according to this entry code https://www.kancloud.cn/inbuf...
verifies there in Chapter 6 and finds that no matter whether the verification is correct or not, the error database table does not exist. At that time, I was not sure that the database table must not have been created successfully, and I was afraid that there were other reasons, so I looked up the reason from the verification chapter, and finally found that there was a problem with the data migration in Chapter 5, Section 2. It should have failed when the table was created here.

 // create the table
        $table = $this->table("users");
        $table->addColumn("name", "string")
            ->addColumn("email", "string")
            ->addColumn("password", "string")
            ->addColumn("avatar", "string", ["null" => true, "default"=>NULL, "comment"=>""])
            ->addColumn("god", "boolean", ["default"=>FALSE, "comment"=>""])
            ->addTimestamps("created_at", "updated_at")
            ->addIndex("email", ["unique" => true])
            ->addIndex("god")
            ->create();

this is also in my code, so I don"t know why the table was not created successfully.

Apr.29,2022

found the answer by himself.
http://docs.phinx.org/en/late...
document is introduced to

.
Please be aware that when a change method exists, Phinx will automatically ignore the up and down methods.

that is, when the change method exists, Phinx automatically ignores the up and down methods.

and I couldn't create the users table before because the up and down methods were added to the migration file it automatically created, but the automatically added change method was empty, but I didn't delete it or comment it out. It comes in front of the up and down methods.

Menu