php - Can't migrate all tables after deleting it manually from database - CodeIgniter 4

Hell i have created two migrations in codeigniter 4 and migrate it. But after it i deleted it manually from database and now when i run the command

php spark migrate

this only create table for last migration only in the database

This is my first time using CodeIgniter 4 and didn't use database migrations before. I was doing a manually created database and dealt with but this time i want learn migrations and the project in this way but i got stuck in this problem

Migration for users:

<?php namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class TblUsers extends Migration
{
    public function up()
    {
//        $this->db->disableForeignKeyChecks();
        $this->forge->addField([
            'user_id' => [
                'type' => 'int',
                'auto_increment' => true
            ],
            'first_name' => [
                'type' => 'varchar',
                'constraint' => 255
            ],
            'last_name' => [
                'type' => 'varchar',
                'constraint' => 255
            ],
            'dob' => [
                'type' => 'date'
            ],
            'contact' => [
                'type' => 'varchar',
                'constraint' => 255
            ],
            'email' => [
                'type' => 'varchar',
                'constraint' => 255
            ],
            'password' => [
                'type' => 'varchar',
                'constraint' => 255
            ],
            'role_id' => [
                'type' => 'int'
            ],
            'created_by' => [
                'type' => 'int'
            ],
            'created_at datetime default current_timestamp',
            'updated_by' => [
                'type' => 'int'
            ],
            'updated_at datetime default current_timestamp on update current_timestamp'
        ]);
        $this->forge->addPrimaryKey('user_id');
        $this->forge->addForeignKey('role_id','tbl_user_roles','role_id','cascade', 'SET NULL');
        $this->forge->createTable('tbl_users');
//        $this->db->enableForeignKeyChecks();
    }

    //

Migration for user roles:

{-code-3}

Directory structor for migrations

enter image description here

Database table created after migrated

enter image description here

Migration in CLI

enter image description here

Answer

Answer

Answer

Answer

Answer

Answer

-------- public function down() { $this->db->disableForeignKeyChecks(); $this->forge->dropTable('tbl_users'); $this->db->enableForeignKeyChecks(); } }|||<?php namespace App\Database\Migrations; use CodeIgniter\Database\Migration; class TblUserRoles extends Migration { public function up() { $this->forge->addField([ 'role_id' => [ 'type' => 'int', 'auto_increment' => true ], 'role' => [ 'type' => 'varchar', 'constraint' => 255 ], 'created_by' => [ 'type' => 'int' ], 'created_at datetime default current_timestamp', 'updated_by' => [ 'type' => 'int' ], 'updated_at datetime default current_timestamp on update current_timestamp' ]); $this->forge->addPrimaryKey('role_id'); $this->forge->createTable('tbl_user_roles'); } //

Answer

Answer

Answer

Answer

Answer

Answer

-------- public function down() { // } }

Source