Advertisement
muhidins

siswa_table

Feb 12th, 2021
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php namespace App\Database\Migrations;
  2.  
  3. use CodeIgniter\Database\Migration;
  4.  
  5. class Students extends Migration
  6. {
  7. public function up()
  8. {
  9. $this->forge->addField([
  10. 'id' => [
  11. 'type' => 'INT',
  12. 'unsigned' => true,
  13. 'auto_increment' => true,
  14. ],
  15. 'nis' => [
  16. 'type' => 'VARCHAR',
  17. 'constraint' => '15',
  18. 'null' => true,
  19. ],
  20. 'name' => [
  21. 'type' => 'VARCHAR',
  22. 'constraint' => '75',
  23. 'null' => true,
  24. ],
  25. 'gender' => [
  26. 'type' => 'CHAR',
  27. 'constraint' => '1',
  28. 'null' => true,
  29. ],
  30. 'username' => [
  31. 'type' => 'VARCHAR',
  32. 'constraint' => '25',
  33. 'null' => true,
  34. ],
  35. 'password' => [
  36. 'type' => 'VARCHAR',
  37. 'constraint' => '65',
  38. 'null' => true,
  39. ],
  40. 'pob' => [
  41. 'type' => 'VARCHAR',
  42. 'constraint' => '50',
  43. 'null' => true,
  44. ],
  45. 'dob' => [
  46. 'type' => 'DATE',
  47. ],
  48. 'grade_id' => [
  49. 'type' => 'INT',
  50. 'unsigned' => true,
  51. 'null' => true,
  52. ],
  53. 'email' => [
  54. 'type' => 'VARCHAR',
  55. 'constraint' => '100',
  56. 'null' => true,
  57. ],
  58. 'phone' => [
  59. 'type' => 'VARCHAR',
  60. 'constraint' => '31',
  61. 'null' => true,
  62. ],
  63. 'active' => [
  64. 'type' => 'ENUM',
  65. 'constraint' => ['Y', 'N'],
  66. 'default' => 'N',
  67. ],
  68. 'candidate_id' => [
  69. 'type' => 'INT',
  70. 'unsigned' => true,
  71. 'null' => true,
  72. ],
  73. 'photo' => [
  74. 'type' => 'VARCHAR',
  75. 'constraint' => '100',
  76. 'null' => true,
  77. ],
  78. ]);
  79. $this->forge->addKey('id', true);
  80. $this->forge->addForeignKey('grade_id','grades','id','CASCADE','CASCADE');
  81. $this->forge->addForeignKey('candidate_id','candidates','id','CASCADE','CASCADE');
  82. $this->forge->createTable('students');
  83. }
  84.  
  85. //--------------------------------------------------------------------
  86.  
  87. public function down()
  88. {
  89. $this->forge->dropTable('students');
  90. }
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement