Schema::table('users', function ($table) {
$table->string('name', 50)->change();
});
public function up()
{
// !!
//if error => Unknown database type enum requested
// add this line
Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
Schema::table('building', function (Blueprint $table) {
$table->float('height' , 10, 2)->change();
});
}
//don't forget reverse
public function down()
{
Schema::table('building', function (Blueprint $table) {
$table->bigInteger('epaisseur')->change();
});
}
public function up()
{
Schema::table('sometable', function (Blueprint $table) {
$table->text('text')->change();
});
}
Schema::table('users', function ($table) {
$table->string('name', 50)->change();
});
We could also modify a column to be nullable:
Schema::table('users', function ($table) {
$table->string('name', 50)->nullable()->change();
});
$table-><column_type>('<column_name>')->change();
public function changeColumnType($table, $column, $newColumnType) {
DB::statement("ALTER TABLE $table CHANGE $column $column $newColumnType");
}