Remove old 'active' column and replace some references with 'suspended' in place

This commit is contained in:
Dane Everitt 2016-09-01 21:21:01 -04:00
parent 38eae88bd0
commit 8e657a0bf0
5 changed files with 37 additions and 8 deletions

View File

@ -67,7 +67,7 @@ class RunTasks extends Command
*/
public function handle()
{
$tasks = Models\Task::where('queued', 0)->where('active', 1)->where('next_run', '<=', (Carbon::now())->toAtomString())->get();
$tasks = Models\Task::where('queued', 0)->where('suspended', 0)->where('next_run', '<=', (Carbon::now())->toAtomString())->get();
$this->info(sprintf('Preparing to queue %d tasks.', count($tasks)));
$bar = $this->output->createProgressBar(count($tasks));

View File

@ -69,7 +69,6 @@ class UserController extends Controller
->join('nodes', 'servers.node', '=', 'nodes.id')
->join('locations', 'nodes.location', '=', 'locations.id')
->where('owner', $id)
->where('active', 1)
->get(),
]);
}

View File

@ -59,7 +59,7 @@ class Server extends Model
*/
protected $casts = [
'node' => 'integer',
'active' => 'integer',
'suspended' => 'integer',
'owner' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
@ -117,7 +117,7 @@ class Server extends Model
/**
* Returns array of all servers owned by the logged in user.
* Returns all active servers if user is a root admin.
* Returns all users servers if user is a root admin.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
@ -132,8 +132,7 @@ class Server extends Model
'allocations.port'
)->join('nodes', 'servers.node', '=', 'nodes.id')
->join('locations', 'nodes.location', '=', 'locations.id')
->join('allocations', 'servers.allocation', '=', 'allocations.id')
->where('active', 1);
->join('allocations', 'servers.allocation', '=', 'allocations.id');
if (self::$user->root_admin !== 1) {
$query->whereIn('servers.id', Subuser::accessServers());
@ -164,7 +163,7 @@ class Server extends Model
$query = self::select('servers.*', 'services.file as a_serviceFile')
->join('services', 'services.id', '=', 'servers.service')
->where('uuidShort', $uuid)->where('active', 1);
->where('uuidShort', $uuid);
if (self::$user->root_admin !== 1) {
$query->whereIn('servers.id', Subuser::accessServers());

View File

@ -205,7 +205,7 @@ class ServerRepository
'uuidShort' => $uuid->generateShort('servers', 'uuidShort', $generatedUuid),
'node' => $data['node'],
'name' => $data['name'],
'active' => 1,
'suspended' => 0,
'owner' => $user->id,
'memory' => $data['memory'],
'swap' => $data['swap'],

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RemoveActiveColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('active');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->tinyInteger('active')->after('name')->unsigned()->default(0);
});
}
}