Skip to content

Commit f431294

Browse files
vijaythecoderclaude
andcommitted
fix: prevent duplicate template seeding on app startup
- Changed NativeAppServiceProvider to check for existing system templates instead of user count - Updated MeetingTemplateSeeder to use firstOrCreate() to prevent duplicates - Ensures templates are only seeded once on first app launch 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 74c3db3 commit f431294

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"mcp__sequential-thinking__sequentialthinking"
5+
],
6+
"deny": []
7+
}
8+
}

app/Providers/NativeAppServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Providers;
44

5-
use App\Models\User;
5+
use App\Models\Template;
66
// use Native\Laravel\Facades\GlobalShortcut;
77
use Illuminate\Support\Facades\Artisan;
88
use Illuminate\Support\Facades\Schema;
@@ -66,8 +66,8 @@ public function phpIni(): array
6666
protected function seedDatabaseIfNeeded(): void
6767
{
6868
try {
69-
// Check if users table exists and has data
70-
if (Schema::hasTable('users') && User::count() === 0) {
69+
// Check if templates table exists and has system templates
70+
if (Schema::hasTable('templates') && !Template::where('is_system', true)->exists()) {
7171
// Run database seeder for initial data
7272
Artisan::call('db:seed', ['--force' => true]);
7373
}

database/seeders/MeetingTemplateSeeder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,13 @@ public function run(): void
684684
];
685685

686686
foreach ($templates as $template) {
687-
Template::create($template);
687+
Template::firstOrCreate(
688+
[
689+
'name' => $template['name'],
690+
'is_system' => true
691+
],
692+
$template
693+
);
688694
}
689695
}
690696
}

0 commit comments

Comments
 (0)