I'm using Laravel migration files to help set up a MariaDB schema for my project. It works fine for the initial table setup of the schema, but after it has been created, how (if it's even possible at all) can I add one field to a migration file and have just that one field be created in the DB without affecting any of the existing fields/data?
As an example, let's say I have an up
method like the following:
public function up()
{
Schema::create('test_table', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
And then I want to add a desc
field as follows:
public function up()
{
Schema::create('test_table', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('desc')->nullable();
$table->timestamps();
});
}
If I run php artisan migrate
after adding the desc
field, will it work as intended, or will it mess up pre-existing stuff? I'm afraid to try without knowing what will happen, and I wanted to check first.
Also, I tried looking at the Laravel documentation for an answer to this question (https://laravel.com/docs/5.7/migrations), but couldn't find anything relevant.
Thanks.