Answer the question
In order to leave comments, you need to log in
How to perform the correct Laravel migration?
There is a written migration
public function up()
{
Schema::create('auto', function (Blueprint $table) {
$table->increments('id');
$table->string('auto');
$table->string('uri');
$table->string('model');
$table->string('number');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('auto');
}
Answer the question
In order to leave comments, you need to log in
Better, create a new migration and make the changes you need in it, it’s better not to change the already created migration, but there are different cases. Take a look here
https://stackoverflow.com/questions/90505/rollback-one-specific-migration-in-laravel
Create a new migration and use the change method
Schema::table('users', function (Blueprint $table) {
$table->string('name', 50)->change();
});
You cannot make changes to the migration. You need to create a new one.
// удаляем поле
Schema::table('auto', function (Blueprint $table) {
$table->dropColumn('remove_field');
});
// добавляем поле
Schema::table('auto', function (Blueprint $table) {
$table->integer('add_field')->nullable();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question