Skip to content

Commit 8e657a0

Browse files
committed
Remove old 'active' column and replace some references with 'suspended' in place
1 parent 38eae88 commit 8e657a0

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

app/Console/Commands/RunTasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct()
6767
*/
6868
public function handle()
6969
{
70-
$tasks = Models\Task::where('queued', 0)->where('active', 1)->where('next_run', '<=', (Carbon::now())->toAtomString())->get();
70+
$tasks = Models\Task::where('queued', 0)->where('suspended', 0)->where('next_run', '<=', (Carbon::now())->toAtomString())->get();
7171

7272
$this->info(sprintf('Preparing to queue %d tasks.', count($tasks)));
7373
$bar = $this->output->createProgressBar(count($tasks));

app/Http/Controllers/Admin/UserController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function getView(Request $request, $id)
6969
->join('nodes', 'servers.node', '=', 'nodes.id')
7070
->join('locations', 'nodes.location', '=', 'locations.id')
7171
->where('owner', $id)
72-
->where('active', 1)
7372
->get(),
7473
]);
7574
}

app/Models/Server.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Server extends Model
5959
*/
6060
protected $casts = [
6161
'node' => 'integer',
62-
'active' => 'integer',
62+
'suspended' => 'integer',
6363
'owner' => 'integer',
6464
'memory' => 'integer',
6565
'swap' => 'integer',
@@ -117,7 +117,7 @@ protected static function getUserDaemonSecret(Server $server)
117117

118118
/**
119119
* Returns array of all servers owned by the logged in user.
120-
* Returns all active servers if user is a root admin.
120+
* Returns all users servers if user is a root admin.
121121
*
122122
* @return \Illuminate\Database\Eloquent\Collection
123123
*/
@@ -132,8 +132,7 @@ public static function getUserServers($paginate = null)
132132
'allocations.port'
133133
)->join('nodes', 'servers.node', '=', 'nodes.id')
134134
->join('locations', 'nodes.location', '=', 'locations.id')
135-
->join('allocations', 'servers.allocation', '=', 'allocations.id')
136-
->where('active', 1);
135+
->join('allocations', 'servers.allocation', '=', 'allocations.id');
137136

138137
if (self::$user->root_admin !== 1) {
139138
$query->whereIn('servers.id', Subuser::accessServers());
@@ -164,7 +163,7 @@ public static function getByUUID($uuid)
164163

165164
$query = self::select('servers.*', 'services.file as a_serviceFile')
166165
->join('services', 'services.id', '=', 'servers.service')
167-
->where('uuidShort', $uuid)->where('active', 1);
166+
->where('uuidShort', $uuid);
168167

169168
if (self::$user->root_admin !== 1) {
170169
$query->whereIn('servers.id', Subuser::accessServers());

app/Repositories/ServerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function create(array $data)
205205
'uuidShort' => $uuid->generateShort('servers', 'uuidShort', $generatedUuid),
206206
'node' => $data['node'],
207207
'name' => $data['name'],
208-
'active' => 1,
208+
'suspended' => 0,
209209
'owner' => $user->id,
210210
'memory' => $data['memory'],
211211
'swap' => $data['swap'],
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class RemoveActiveColumn extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('servers', function (Blueprint $table) {
16+
$table->dropColumn('active');
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
Schema::table('servers', function (Blueprint $table) {
28+
$table->tinyInteger('active')->after('name')->unsigned()->default(0);
29+
});
30+
}
31+
}

0 commit comments

Comments
 (0)