Romanovich095

CodeIgniter 3.x Migrations example

Aug 6th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('Forbidden');
  3.  
  4. /**
  5.  * Class Migration_create_users_table
  6.  * @property CI_DB_forge $Forge
  7.  */
  8. class Migration_create_users_table extends CI_Migration
  9. {
  10.     public function up()
  11.     {
  12.         $this->Forge
  13.             ->add_field([
  14.                 [
  15.                     'username' => [
  16.                         'type' => 'VARCHAR',
  17.                         'constraint' => 30
  18.                     ],
  19.                     'password' => [
  20.                         'type' => 'VARCHAR',
  21.                         'constraint' => 255
  22.                     ],
  23.                     'active' => [
  24.                         'type' => 'BOOLEAN',
  25.                         'default' => 0
  26.                     ]
  27.                 ]
  28.             ])
  29.             ->add_key('id');
  30.  
  31.         $this->Forge
  32.             ->create_table('table', true);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment