-
Hello Everyone, <?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
// Add custom column for shield
class AddCustomColumnForUser extends Migration
{
public function up()
{
$fields = [
'first_name' => [
'type' => 'text',
'constraint' => '50',
'null' => TRUE
],
'last_name' => [
'type' => 'VARCHAR',
'constraint' => '50',
'null' => TRUE
],
'phone_number' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => TRUE
]
];
$this->forge->addColumn('users', $fields);
}
public function down()
{
$fields = [
'first_name',
'last_name',
'phone_number',
];
$this->forge->dropColumn('users', $fields);
}
} here is CLI result |
Beta Was this translation helpful? Give feedback.
Answered by
datamweb
Sep 10, 2022
Replies: 1 comment 1 reply
-
Hey @khan-umer , <?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
// Add custom column for shield
class AddCustomColumnForUser extends Migration
{
public function up()
{
$fields = [
'first_name' => [
'type' => 'text',
'constraint' => '50',
'null' => TRUE
],
'last_name' => [
'type' => 'VARCHAR',
'constraint' => '50',
'null' => TRUE
],
'phone_number' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => TRUE
]
];
$this->forge->addColumn('users', $fields);
}
public function down()
{
$fields = [
'first_name',
'last_name',
'phone_number',
];
$this->forge->dropColumn('users', $fields);
}
} Now run command |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
datamweb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @khan-umer ,
Please delete file
AddCustomColumnForUser.php
from pathapp\Database\Migrations
.Now run command
php spark make:migration AddCustomColumnForUser
.Edit this file and add the following: