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
Database table created after migrated
Migration in CLI