Perintah untuk membuat migrasi
php spark make:migration <nama_migration>Selanjutnya akan membuat file app/Database/Migrations/data_users.php
namespace App\Database\Migrations; use CodeIgniter\Database\Migration; class Users extends Migration { public function up() { // $this->forge->addField( array( 'id' => array( 'type' => 'INT', 'constraint' => 5, 'unsigned' => true, 'auto_increment' => true ), 'name' => array( 'type' => 'VARCHAR', 'constraint' => '100', ), 'email' => array( 'type' => 'TEXT', 'null' => true, ), ) ); $this->forge->addKey('id', TRUE); $this->forge->createTable('users'); } public function down() { // $this->forge->drop_table('users'); } }Perintah untuk menjalankan migrasi :
php spark migrate
Tags:
Tutorial PHP