{"record":{"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":"error","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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Console/Migrations/MigrateCommand.php#L208-L244","documentation":"Thrown by MigrateCommand when the SQLite database file is missing and the user declines the interactive prompt that offers to create it (or creation is skipped under --no-interaction without --force). It is an intentional abort: the migration refuses to run against a non-existent file the user did not authorize creating.","triggerScenarios":"Running `php artisan migrate` against a sqlite connection whose file does not exist; the command shows 'The SQLite database ... does not exist' and a confirm prompt; the user answers 'no', or runs with --no-interaction (which makes the prompt return false), causing the RuntimeException.","commonSituations":"Fresh clone on a CI/production server where the sqlite file is not pre-created and the deploy runs with --no-interaction; local setup where the developer cancels the prompt; switching an app to sqlite for the first time.","solutions":["Pre-create the file: touch database/database.sqlite before running migrations.","Run interactively and answer 'yes' to the create prompt.","Use --force to bypass the guard where appropriate (still requires the file path to be creatable): ensure the file exists beforehand rather than relying on the prompt.","Point DB_DATABASE at an existing file path, or use :memory: for ephemeral test runs."],"exampleFix":"// before\nphp artisan migrate --no-interaction   # sqlite file missing -> aborts\n\n// after\ntouch database/database.sqlite\nphp artisan migrate","handlingStrategy":"validation","validationCode":"if ($connection->getDriverName() === 'sqlite'\n    && ! file_exists($connection->getDatabaseName())\n    && ($forceCreate || ! $this->option('no-interaction'))) {\n    touch($connection->getDatabaseName());\n}","typeGuard":"function sqliteFileReady(string $path): bool {\n    return $path === ':memory:' || file_exists($path);\n}","tryCatchPattern":"try {\n    Artisan::call('migrate');\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Database was not created')) {\n        touch(database_path('database.sqlite'));\n        Artisan::call('migrate');\n    } else { throw $e; }\n}","preventionTips":["Pre-create the SQLite file in deployment (touch database/database.sqlite).","In non-interactive CI, ensure the file exists before running migrate.","Bootstrap scripts should assert the sqlite file exists before `artisan migrate`."],"tags":["database","sqlite","migrations","console","artisan","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}