I am trying to fix the bug with my Laravel project build and want to understand what steps exactly are done by php artisan migrate command.
The project uses my custom package.
- I've created a migration in the package, which adds a new column to the existing table:
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->boolean('is_good_product')->default(0);
});
}
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('is_good_product');
});
}
- Then I put the tag to the package version in my project composer.json file
'package: dev-master#tag-number'
and ran composer update package to update .lock file.
3.1. If I run the 'php artisan migrate' command locally I see that the new migration runs and creates needed column.
3.2. But building the branch on the remote stage server says the following error.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'is_good_product' in 'where clause' (SQL: select `name` from `products` where `is_good_product` = 1)
I see this error when trying to migrate, rollback, refresh, truncate the database. Only creating the column manually helps me do rollback and then migrate.
Why Connection.php file is looking for this column? Is the migration from the package was started but wasn't finished? Or what else could happen?
[Edit] In other words - why 'artisan migrate' command complains about unknown column of newly added migration file? (it if should run it and add the column). And how Connection.php file can know about the column if the migration didn't run (as column wasn't created)?