-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_roles.php
More file actions
87 lines (70 loc) · 2.35 KB
/
fix_roles.php
File metadata and controls
87 lines (70 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require_once __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
echo "Veritabanı migration işlemleri başlatılıyor..." . PHP_EOL;
echo "Configuration önbelleği temizleniyor..." . PHP_EOL;
system('php artisan config:clear');
echo "View önbelleği temizleniyor..." . PHP_EOL;
system('php artisan view:clear');
echo "Route önbelleği temizleniyor..." . PHP_EOL;
system('php artisan route:clear');
echo "Migration'lar sıfırdan çalıştırılıyor..." . PHP_EOL;
system('php artisan migrate:fresh');
echo "İşlem tamamlandı!" . PHP_EOL;
try {
echo "Roles tablosunu kontrol ediyorum...\n";
if (!Schema::hasTable('roles')) {
echo "roles tablosu bulunamadı. Önce migration'ları çalıştırın.\n";
exit(1);
}
$hasDescriptionColumn = Schema::hasColumn('roles', 'description');
if ($hasDescriptionColumn) {
DB::table('roles')->updateOrInsert(
['id' => 0],
[
'name' => 'admin',
'description' => 'Administrator',
'created_at' => now(),
'updated_at' => now()
]
);
DB::table('roles')->updateOrInsert(
['id' => 1],
[
'name' => 'user',
'description' => 'User',
'created_at' => now(),
'updated_at' => now()
]
);
} else {
DB::table('roles')->updateOrInsert(
['id' => 0],
[
'name' => 'admin',
'created_at' => now(),
'updated_at' => now()
]
);
DB::table('roles')->updateOrInsert(
['id' => 1],
[
'name' => 'user',
'created_at' => now(),
'updated_at' => now()
]
);
}
echo "Roller başarıyla eklendi veya güncellendi!\n";
$roles = DB::table('roles')->get();
echo "Roller tablosu içeriği:\n";
foreach ($roles as $role) {
echo "ID: {$role->id}, Name: {$role->name}\n";
}
} catch (\Exception $e) {
echo "Hata oluştu: " . $e->getMessage() . "\n";
exit(1);
}