{"id":"3c5b3d46c5a9f353","repo":"laravel/framework","slug":"database-was-not-created-aborting-migration","errorCode":null,"errorMessage":"Database was not created. Aborting migration.","messagePattern":"Database was not created\\. Aborting migration\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"src/Illuminate/Database/Console/Migrations/MigrateCommand.php","lineNumber":226,"sourceCode":"     *\n     * @throws \\RuntimeException\n     */\n    protected function createMissingSqliteDatabase($path)\n    {\n        if ($this->option('force')) {\n            return touch($path);\n        }\n\n        if ($this->option('no-interaction')) {\n            return false;\n        }\n\n        $this->components->warn('The SQLite database configured for this application does not exist: '.$path);\n\n        if (! confirm('Would you like to create it?', default: true)) {\n            $this->components->info('Operation cancelled. No database was created.');\n\n            throw new RuntimeException('Database was not created. Aborting migration.');\n        }\n\n        return touch($path);\n    }\n\n    /**\n     * Create a missing MySQL or Postgres database.\n     *\n     * @param  \\Illuminate\\Database\\Connection  $connection\n     * @return bool\n     *\n     * @throws \\RuntimeException\n     */\n    protected function createMissingMySqlOrPgsqlDatabase($connection)\n    {\n        if ($this->laravel['config']->get(\"database.connections.{$connection->getName()}.database\") !== $connection->getDatabaseName()) {\n            return false;\n        }","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Console/Migrations/MigrateCommand.php#L208-L244","documentation":"Thrown by MigrateCommand::createMissingSqliteDatabase() when, during a migration, the configured SQLite file does not exist and the user answers 'no' to the 'Would you like to create it?' confirm prompt (or the prompt is skipped under --no-interaction without --force). It aborts the migration rather than silently working on a non-existent file.","triggerScenarios":"Running `php artisan migrate` against a sqlite connection whose database file is missing, then declining the interactive prompt; or running with --no-interaction (and not --force), which short-circuits the prompt and returns false, aborting.","commonSituations":"CI/CD running `php artisan migrate --no-interaction` on a fresh checkout without the SQLite file present; a deploy where the artifact doesn't include the .sqlite file; locally deleting the file and re-running migrations.","solutions":["Pre-create the file before migrating: touch database/database.sqlite.","Run with --force to auto-create: php artisan migrate --force.","In CI, either ship the empty SQLite file or add a `touch`/migrate step with --force.","Answer 'yes' to the interactive prompt when running locally."],"exampleFix":"# before\nphp artisan migrate --no-interaction  # aborts\n\n# after\ntouch database/database.sqlite\nphp artisan migrate --no-interaction\n# or\nphp artisan migrate --force","handlingStrategy":"validation","validationCode":"if (($path = config('database.connections.sqlite.database')) && $path !== ':memory:' && ! is_file($path)) {\n    @touch($path);\n}","typeGuard":"function sqliteFileReady(string $path): bool {\n    return $path === ':memory:' || str_starts_with($path, 'file:') || is_file($path);\n}","tryCatchPattern":null,"preventionTips":["Pre-create the SQLite file in CI/deploy scripts.","Run `php artisan migrate --force` in non-interactive contexts.","Use :memory: for test suites.","Document that the create-database prompt is skipped under --no-interaction."],"tags":["console","migrations","sqlite","ci"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}