-
-
Notifications
You must be signed in to change notification settings - Fork 28
Description
What were you trying to do?
When publishing the app for mac > arm64, the SQLite db is being migrated just fine, but the seeding is never working, even when I try to create the default user in NativeAppServiceProvider without seeding, still can't make it work.
What happened?
The app works fine, but as I mentioned above, the seeding isn't working.
Also, I have a second SQLite db for data simulation, but I can't get it to migrate and seed the mock data.
How to reproduce the bug
I use the latest NativePHP v2.1.1.
Laravel v12.53.0.
I use SQLite for db.
The dev run works fine because I run the seeder in the terminal.
I run php artisan native:publish, the process runs without any errors.
Debug Output
{
"Environment": {
"PHP": {
"Version": "8.3.30",
"Path": "/Applications/MAMP/bin/php/php8.3.30/bin/php"
},
"Laravel": {
"Version": "12.53.0",
"ConfigCached": true,
"RoutesCached": true,
"DebugEnabled": true
},
"Node": {
"Version": "v22.22.0",
"Path": "/Users/zahraah/.nvm/versions/node/v22.22.0/bin/node"
},
"NPM": {
"Version": "10.9.4",
"Path": "/Users/zahraah/.nvm/versions/node/v22.22.0/bin/npm"
},
"OperatingSystem": "Darwin",
"ElectronRoot": "nativephp/electron/"
},
"NativePHP": {
"Versions": {
"nativephp/desktop": "2.1.1.0",
"nativephp/php-bin": "1.1.1.0"
},
"Configuration": {
"Provider": "App\Providers\NativeAppServiceProvider",
"BuildHooks": {
"Pre": [
"npm run build",
"php artisan optimize"
],
"Post": []
},
"NotarizationEnabled": false,
"AzureTrustedSigningEnabled": false,
"CustomPHPBinary": false
}
}
}
Which operating systems have you seen this occur on?
macOS 26.3
Notes
I tried
public function boot(): void
{
// 1) Ensure default admin user
try {
Log::info('NativeAppServiceProvider::boot');
if (User::where('email', 'admin@example.com')->doesntExist()) {
// Users table must already exist (Electron has run migrations)
User::factory()->create([
'name' => 'Admin User',
'email' => 'admin@example.com',
// Will be hashed because of the User model's `password` cast
'password' => Hash::make('waleed@admin'),
]);
}
} catch (\Throwable $e) {
Log::error('Failed to ensure default user: ' . $e->getMessage());
}
// 2) Ensure oracle_sim schema + data
try {
// If oracle_sim tables are not there yet, migrate that connection
Log::info('Checking if oracle_sim tables exist');
if (!DB::connection('oracle_sim')->hasTable('GROUP_DETAILS')) {
Artisan::call('migrate', [
'--database' => 'oracle_sim',
'--path' => 'database/migrations/oracle_sim',
'--force' => true,
]);
}
// If there is no data yet, seed oracle_sim
$groupCount = DB::connection('oracle_sim')->table('GROUP_DETAILS')->count();
if ($groupCount === 0) {
Artisan::call('db:seed', [
'--class' => 'Database\\Seeders\\OracleSimSeeder',
'--force' => true,
]);
// Note: OracleSimSeeder already has `$connection = 'oracle_sim'`,
// so you don't need `--database` here unless you really want to.
}
} catch (\Throwable $e) {
Log::error('Failed to prepare oracle_sim database: ' . $e->getMessage());
}
$width = 1024;
$height = 768;
Window::open()
->width($width)
->height($height);
}
And also tried to run
try {
Log::info('NativeAppServiceProvider::boot');
if (User::count() === 0) {
Artisan::call('db:seed', ['--force' => true]);
}
} catch (\Throwable $e) {
Log::error('Failed to ensure default user: ' . $e->getMessage());
}
$width = 1024;
$height = 768;
Window::open()
->width($width)
->height($height);
And also tried the code from the NativePHP docs
Docs
nothing seems to work
Any help will be appreciated.
Thank you