Skip code quality checks during migrations, require DB provisioning
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1498,7 +1498,9 @@ class Manifest
|
||||
\Illuminate\Support\Facades\Artisan::call('view:clear', [], new \Symfony\Component\Console\Output\NullOutput());
|
||||
|
||||
// Run manifest-time code quality checks (development only)
|
||||
if (env('APP_ENV') !== 'production' && $changes) {
|
||||
// Skip during migrations - database may not be provisioned yet
|
||||
if (env('APP_ENV') !== 'production' && $changes && !static::__is_migration_context()) {
|
||||
static::__verify_database_provisioned();
|
||||
static::__run_manifest_time_code_quality_checks();
|
||||
}
|
||||
|
||||
@@ -3609,6 +3611,77 @@ class Manifest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're running in a migration context
|
||||
*
|
||||
* Returns true if running migrate, make:migration, or other DB setup commands.
|
||||
* Used to skip code quality checks that depend on database state.
|
||||
*/
|
||||
protected static function __is_migration_context(): bool
|
||||
{
|
||||
// Check if running from CLI
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the artisan command being run
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
if (count($argv) < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Commands that should skip code quality checks
|
||||
$migration_commands = [
|
||||
'migrate',
|
||||
'migrate:fresh',
|
||||
'migrate:install',
|
||||
'migrate:refresh',
|
||||
'migrate:reset',
|
||||
'migrate:rollback',
|
||||
'migrate:status',
|
||||
'make:migration',
|
||||
'make:migration:safe',
|
||||
'db:seed',
|
||||
'db:wipe',
|
||||
];
|
||||
|
||||
$command = $argv[1] ?? '';
|
||||
return in_array($command, $migration_commands, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify database has been provisioned before running code quality checks
|
||||
*
|
||||
* Checks that required framework tables (_manifest, _session) exist.
|
||||
* If not, throws a fatal error instructing the user to run migrations.
|
||||
* This prevents confusing code quality errors when the real issue is
|
||||
* that migrations haven't been run yet.
|
||||
*/
|
||||
protected static function __verify_database_provisioned(): void
|
||||
{
|
||||
$required_tables = ['_manifest', '_session'];
|
||||
$missing_tables = [];
|
||||
|
||||
foreach ($required_tables as $table) {
|
||||
if (!\Illuminate\Support\Facades\Schema::hasTable($table)) {
|
||||
$missing_tables[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missing_tables)) {
|
||||
$tables_list = implode(', ', $missing_tables);
|
||||
throw new \RuntimeException(
|
||||
"Database not provisioned - required tables missing: {$tables_list}\n\n" .
|
||||
"Run migrations before continuing:\n" .
|
||||
" php artisan migrate\n\n" .
|
||||
"If this is a fresh installation, you may also need to:\n" .
|
||||
" 1. Create the database\n" .
|
||||
" 2. Configure .env with correct DB_* settings\n" .
|
||||
" 3. Run: php artisan migrate"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all database tables from manifest model metadata
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user