-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
What were you trying to do?
Converting existing project to nativephp.
Migrate database using php artisan native:migrate
.
What happened?
Instead of loading and executing the ./database/schema/sqlite-schema.sql
, it says: Nothing to migrate.
More about squashing migrations : https://laravel.com/docs/11.x/migrations#squashing-migrations
How to reproduce the bug
if you already did composer native:dev
, then manually delete sqlite db file from /database
directory.
- create a new laravel 11 project or If you are on laravel version 10 or lower, upgrade to laravel 11.
- at project root run
touch ./database/demo.sqlite
- Update .env
DB_DATABASE
value todemo
- Run
php artisan migrate:fresh --database=sqlite
- Use the squash command
php artisan schema:dump --database=sqlite --prune
to clear individual migration files and clean up the project or if you have unsupported column modifiers. (WARNING: existing table wise migrations files will be deleted) - Run
touch ./database/nativephp.sqlite
- Run
php artisan native:migrate
Debug Output
{
"Environment": {
"PHP": {
"Version": "8.3.19",
"Path": "/opt/homebrew/Cellar/php@8.3/8.3.19/bin/php"
},
"Laravel": {
"Version": "11.44.2",
"ConfigCached": false,
"DebugEnabled": true
},
"Node": {
"Version": "v22.11.0",
"Path": "/Users/Rishab/.nvm/versions/node/v22.11.0/bin/node"
},
"NPM": {
"Version": "10.9.0",
"Path": "/Users/Rishab/.nvm/versions/node/v22.11.0/bin/npm"
},
"OperatingSystem": "Darwin"
},
"NativePHP": {
"Versions": {
"nativephp/electron": "1.0.0.0",
"nativephp/laravel": "1.0.0.0",
"nativephp/php-bin": "1.0.1.0"
},
"Configuration": {
"Provider": "App\Providers\NativeAppServiceProvider",
"BuildHooks": {
"Pre": [],
"Post": []
},
"NotarizationEnabled": false,
"CustomPHPBinary": false
}
}
}
Which operating systems have you seen this occur on?
macOS
Notes
Temporary fix:
- Run
php artisan make:migration native_schema_loader
- update the up() method of the new migration:
public function up(): void
{
if (app()->runningInConsole() && $this->isRunningNativeMigrate()) {
if (!Schema::hasTable('users')) {
$sql = File::get(database_path('schema/sqlite-schema.sql'));
DB::unprepared($sql);
}
}
}
private function isRunningNativeMigrate(): bool
{
return isset($_SERVER['argv']) && in_array('native:migrate', $_SERVER['argv']);
}
- Run
php artisan native:migrate
But still php artisan native:migrate:fresh
keeps showing 'Dropping all tables. Nothing to migrate' and hence have to drop tables manually via DB client for consequent runs.