As of now Laravel Schema Builder does not support SET datatype for columns. So, here is an alternative solution until someone add those code to Laravel.
Step 1: Create the table, use ENUM instead of SET.
Schema::create('schools', function($table)
{
$table->increments('id');
$table->char('id_number', 6);
$table->string('school_name');
$table->enum('level', array('Preschool', 'Kindergarten', 'Primary', 'Secondary'))->index(); // *** fix this
$table->string('phone');
$table->string('email');
$table->string('location');
$table->smallInteger('city')->unsigned()->index();
$table->smallInteger('country')->unsigned()->index();
$table->smallInteger('head_teacher')->unsigned()->index();
$table->smallInteger('director')->unsigned()->index();
$table->smallInteger('created_by')->unsigned();
$table->smallInteger('modified_by')->unsigned();
$table->timestamps();
});
Now change ENUM to SET.
$table_prefix = DB::getTablePrefix();
DB::statement("ALTER TABLE `" . $table_prefix . "schools` CHANGE `level` `level` SET('Preschool','Kindergarten','Primary','Secondary');");
If you have a better solution, then please let me know.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community