Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace App\Database\Migrations;
- use CodeIgniter\Database\Migration;
- class Students extends Migration
- {
- public function up()
- {
- $this->forge->addField([
- 'id' => [
- 'type' => 'INT',
- 'unsigned' => true,
- 'auto_increment' => true,
- ],
- 'nis' => [
- 'type' => 'VARCHAR',
- 'constraint' => '15',
- 'null' => true,
- ],
- 'name' => [
- 'type' => 'VARCHAR',
- 'constraint' => '75',
- 'null' => true,
- ],
- 'gender' => [
- 'type' => 'CHAR',
- 'constraint' => '1',
- 'null' => true,
- ],
- 'username' => [
- 'type' => 'VARCHAR',
- 'constraint' => '25',
- 'null' => true,
- ],
- 'password' => [
- 'type' => 'VARCHAR',
- 'constraint' => '65',
- 'null' => true,
- ],
- 'pob' => [
- 'type' => 'VARCHAR',
- 'constraint' => '50',
- 'null' => true,
- ],
- 'dob' => [
- 'type' => 'DATE',
- ],
- 'grade_id' => [
- 'type' => 'INT',
- 'unsigned' => true,
- 'null' => true,
- ],
- 'email' => [
- 'type' => 'VARCHAR',
- 'constraint' => '100',
- 'null' => true,
- ],
- 'phone' => [
- 'type' => 'VARCHAR',
- 'constraint' => '31',
- 'null' => true,
- ],
- 'active' => [
- 'type' => 'ENUM',
- 'constraint' => ['Y', 'N'],
- 'default' => 'N',
- ],
- 'candidate_id' => [
- 'type' => 'INT',
- 'unsigned' => true,
- 'null' => true,
- ],
- 'photo' => [
- 'type' => 'VARCHAR',
- 'constraint' => '100',
- 'null' => true,
- ],
- ]);
- $this->forge->addKey('id', true);
- $this->forge->addForeignKey('grade_id','grades','id','CASCADE','CASCADE');
- $this->forge->addForeignKey('candidate_id','candidates','id','CASCADE','CASCADE');
- $this->forge->createTable('students');
- }
- //--------------------------------------------------------------------
- public function down()
- {
- $this->forge->dropTable('students');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement