Initial implementation of improved sever model and logic

This commit is contained in:
Dane Everitt 2017-02-02 18:21:36 -05:00
parent fb589a7f4e
commit d4bcf0be59
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
31 changed files with 223 additions and 158 deletions

View file

@ -24,7 +24,7 @@ class ModifyIpStorageMethod extends Migration
[
'ip' => $server->ip,
'port' => $server->port,
'node' => $server->node,
'node' => $server->node_id,
]
);
@ -61,7 +61,7 @@ class ModifyIpStorageMethod extends Migration
// Find the allocations and reset the servers...
$servers = DB::select('SELECT id, allocation FROM servers');
foreach ($servers as $server) {
$allocation = DB::select('SELECT * FROM allocations WHERE id = :alocid', ['alocid' => $server->allocation]);
$allocation = DB::select('SELECT * FROM allocations WHERE id = :alocid', ['alocid' => $server->allocation_id]);
if (isset($allocation[0])) {
DB::update(

View file

@ -22,7 +22,7 @@ class AddDockerImageColumn extends Migration
$servers = DB::table('servers')->select(
'servers.id',
'service_options.docker_image as s_optionImage'
)->join('service_options', 'service_options.id', '=', 'servers.option')->get();
)->join('service_options', 'service_options.id', '=', 'servers.option_id')->get();
foreach ($servers as $server) {
$server->image = $server->s_optionImage;

View file

@ -0,0 +1,66 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateColumnNames extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropForeign('servers_node_foreign');
$table->dropForeign('servers_owner_foreign');
$table->dropForeign('servers_allocation_foreign');
$table->dropForeign('servers_service_foreign');
$table->dropForeign('servers_option_foreign');
$table->dropIndex('servers_node_foreign');
$table->dropIndex('servers_owner_foreign');
$table->dropIndex('servers_allocation_foreign');
$table->dropIndex('servers_service_foreign');
$table->dropIndex('servers_option_foreign');
$table->renameColumn('node', 'node_id');
$table->renameColumn('owner', 'owner_id');
$table->renameColumn('allocation', 'allocation_id');
$table->renameColumn('service', 'service_id');
$table->renameColumn('option', 'option_id');
$table->renameColumn('pack', 'pack_id');
$table->foreign('node_id')->references('id')->on('nodes');
$table->foreign('owner_id')->references('id')->on('users');
$table->foreign('allocation_id')->references('id')->on('allocations');
$table->foreign('service_id')->references('id')->on('services');
$table->foreign('option_id')->references('id')->on('service_options');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->renameColumn('node_id', 'node');
$table->renameColumn('owner_id', 'owner');
$table->renameColumn('allocation_id', 'allocation');
$table->renameColumn('service_id', 'service');
$table->renameColumn('option_id', 'option');
$table->renameColumn('pack_id', 'pack');
$table->foreign('node')->references('id')->on('nodes');
$table->foreign('owner')->references('id')->on('users');
$table->foreign('allocation')->references('id')->on('allocations');
$table->foreign('service')->references('id')->on('services');
$table->foreign('option')->references('id')->on('service_options');
});
}
}