laravel/framework · error · RuntimeException

Database was not created. Aborting migration.

Error message

Database was not created. Aborting migration.

What it means

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.

Solutions

  1. Pre-create the file: touch database/database.sqlite before running migrations.
  2. Run interactively and answer 'yes' to the create prompt.
  3. 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.
  4. Point DB_DATABASE at an existing file path, or use :memory: for ephemeral test runs.

Example fix

// before
php artisan migrate --no-interaction   # sqlite file missing -> aborts

// after
touch database/database.sqlite
php artisan migrate
Defensive patterns

Strategy: validation

Validate before calling

if ($connection->getDriverName() === 'sqlite'
    && ! file_exists($connection->getDatabaseName())
    && ($forceCreate || ! $this->option('no-interaction'))) {
    touch($connection->getDatabaseName());
}

Type guard

function sqliteFileReady(string $path): bool {
    return $path === ':memory:' || file_exists($path);
}

Try / catch

try {
    Artisan::call('migrate');
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'Database was not created')) {
        touch(database_path('database.sqlite'));
        Artisan::call('migrate');
    } else { throw $e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/3c5b3d46c5a9f353. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Database/Console/Migrations/MigrateCommand.php:226

     *
     * @throws \RuntimeException
     */
    protected function createMissingSqliteDatabase($path)
    {
        if ($this->option('force')) {
            return touch($path);
        }

        if ($this->option('no-interaction')) {
            return false;
        }

        $this->components->warn('The SQLite database configured for this application does not exist: '.$path);

        if (! confirm('Would you like to create it?', default: true)) {
            $this->components->info('Operation cancelled. No database was created.');

            throw new RuntimeException('Database was not created. Aborting migration.');
        }

        return touch($path);
    }

    /**
     * Create a missing MySQL or Postgres database.
     *
     * @param  \Illuminate\Database\Connection  $connection
     * @return bool
     *
     * @throws \RuntimeException
     */
    protected function createMissingMySqlOrPgsqlDatabase($connection)
    {
        if ($this->laravel['config']->get("database.connections.{$connection->getName()}.database") !== $connection->getDatabaseName()) {
            return false;
        }

View on GitHub (pinned to e0f6eb3518)