-
Notifications
You must be signed in to change notification settings - Fork 24
/
InitialiseDatabase.php
65 lines (55 loc) · 1.94 KB
/
InitialiseDatabase.php
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
<?php
namespace Zeropingheroes\LancacheAutofill\Commands\App;
use Illuminate\Console\Command;
use Illuminate\Database\Capsule\Manager as Capsule;
class InitialiseDatabase extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:initialise-database
{--yes : Suppress confirmations}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initialise the database';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (Capsule::schema()->hasTable('steam_apps') OR Capsule::schema()->hasTable('steam_queue') OR Capsule::schema()->hasTable('steam_accounts')) {
if ($this->option('yes') OR $this->confirm('Are you sure you wish to clear all data in the database?')) {
$this->info('Removing existing database tables');
Capsule::schema()->dropIfExists('steam_apps');
Capsule::schema()->dropIfExists('steam_queue');
Capsule::schema()->dropIfExists('steam_accounts');
}
else {
die();
}
}
$this->info('Creating empty database tables');
Capsule::schema()->create('steam_apps', function ($table) {
$table->integer('id')->unique();
$table->string('name');
});
Capsule::schema()->create('steam_queue', function ($table) {
$table->increments('id')->unique();
$table->integer('app_id');
$table->string('status');
$table->string('platform');
$table->integer('popularity')->nullable()->default(1);
$table->string('message')->nullable();
});
Capsule::schema()->create('steam_accounts', function ($table) {
$table->string('username');
});
}
}