Merge all existing migrations into current structure.

This commit is contained in:
James Brooks
2015-01-05 20:38:06 +00:00
parent 048bf5e508
commit 7655e30497
25 changed files with 45 additions and 645 deletions
@@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWebHooksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('web_hooks', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('endpoint')->nullable(false);
$table->tinyInteger('hook_type')->default(0); // When should this web hook be called?
$table->tinyInteger('request_type')->default(0); // ENUM: GET, POST, PUT, DELETE etc
$table->boolean('active')->default(0);
$table->timestamps();
$table->softDeletes();
// Indexes
$table->index('active');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('web_hooks');
}
}
@@ -1,41 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWebHookResponsesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('web_hook_response', function (Blueprint $table) {
$table->increments('id');
$table->integer('hook_id')->unsigned();
$table->tinyInteger('response_code')->nullable(false); // This should return something like 200, 301 etc.
$table->string('response_type'); // application/json etc.
$table->text('sent_headers');
$table->longText('sent_body'); // What we sent the web hook
$table->text('recv_headers');
$table->longText('recv_body'); // Potentially a big response will be returned
$table->float('time_taken')->default(0); // How long did the request take, in seconds.
$table->timestamps();
$table->index('hook_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('web_hook_response');
}
}
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UserIdColumnForComponents extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
$table->dropForeign('components_user_id_foreign');
$table->dropColumn('user_id');
});
}
}
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UserIdColumnForIncidents extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('incidents', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('incidents', function (Blueprint $table) {
$table->dropForeign('incidents_user_id_foreign');
$table->dropColumn('user_id');
});
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableIncidentsRenameComponentColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('incidents', function (Blueprint $table) {
$table->renameColumn('component', 'component_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('incidents', function (Blueprint $table) {
$table->renameColumn('component_id', 'component');
});
}
}
@@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AlterTableIncidentsRemoveDefaultComponent extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('incidents', function (Blueprint $table) {
if (Config::get('database')['default'] === 'mysql') {
DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '0';");
} elseif (Config::get('database')['default'] === 'pgsql') {
DB::statement("ALTER TABLE incidents ALTER COLUMN component_id SET DEFAULT '0';");
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('incidents', function (Blueprint $table) {
if (Config::get('database')['default'] === 'mysql') {
DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '1';");
} elseif (Config::get('database')['default'] === 'pgsql') {
DB::statement("ALTER TABLE incidents ALTER COLUMN component_id SET DEFAULT '1';");
}
});
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSessionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->text('payload');
$table->integer('last_activity');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('sessions');
}
}
@@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableComponentsAddDeletedAt extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableComponentsAddMetaColumns extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->text('tags')->nullable()->default(null)->after('description');
$table->text('link')->nullable()->default(null)->after('description');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('tags');
$table->dropColumn('link');
});
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class AlterTableSettingsValueLongText extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Config::get('database')['default'] === 'mysql') {
DB::statement("ALTER TABLE settings CHANGE `value` `value` LONGTEXT;");
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Config::get('database')['default'] === 'mysql') {
DB::statement("ALTER TABLE settings CHANGE `value` `value` TEXT;");
}
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableComponentsAddOrderColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->tinyInteger('order')->default(0)->after('status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('order');
});
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableUsersAddApiKey extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('api_key')->nullable()->default(null)->after('email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('api_key');
});
}
}
@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableComponentsAddGroupIdColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->integer('group_id')->nullable()->default(null)->after('order');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('group_id');
});
}
}
@@ -17,7 +17,6 @@ class CreateComponentGroupsTable extends Migration
$table->increments('id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
@@ -16,11 +16,20 @@ class CreateComponentsTable extends Migration
Schema::create('components', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description')->nullable()->default(null);
$table->tinyInteger('status')->default(1);
$table->text('description')->default('');
$table->text('link')->default('');
$table->text('tags')->default('');
$table->integer('status');
$table->integer('order');
$table->integer('group_id');
$table->integer('user_id');
$table->timestamps();
$table->softDeletes();
$table->index('group_id');
$table->index('user_id');
$table->index('status');
$table->index('order');
});
}
@@ -15,13 +15,11 @@ class CreateIncidentTemplatesTable extends Migration
{
Schema::create('incident_templates', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('slug', 50)->nullable(false);
$table->longText('template')->nullable(false);
$table->string('name');
$table->string('slug');
$table->longText('template');
$table->timestamps();
$table->index('slug');
$table->softDeletes();
});
}
@@ -15,15 +15,17 @@ class CreateIncidentsTable extends Migration
{
Schema::create('incidents', function (Blueprint $table) {
$table->increments('id');
$table->tinyInteger('component')->default(1);
$table->integer('component_id')->default(0);
$table->string('name');
$table->tinyInteger('status')->default(1);
$table->longText('message');
$table->integer('status');
$table->longText('message')->default('');
$table->integer('user_id');
$table->timestamps();
$table->softDeletes();
$table->index('component');
$table->index('component_id');
$table->index('status');
$table->index('user_id');
});
}
@@ -15,11 +15,11 @@ class CreateMetricPointsTable extends Migration
{
Schema::create('metric_points', function (Blueprint $table) {
$table->increments('id');
$table->integer('metric_id')->unsigned();
$table->integer('value')->unsigned();
$table->integer('metric_id');
$table->integer('value');
$table->timestamps();
$table->foreign('metric_id')->references('id')->on('metrics');
$table->index('metric_id');
});
}
@@ -15,11 +15,13 @@ class CreateMetricsTable extends Migration
{
Schema::create('metrics', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('suffix')->nullable(false);
$table->string('description')->nullable(false);
$table->boolean('display_chart')->default(false);
$table->string('name');
$table->string('suffix');
$table->text('description')->default('');
$table->boolean('display_chart')->default(1);
$table->timestamps();
$table->index('display_chart');
});
}
@@ -15,12 +15,12 @@ class CreateServicesTable extends Migration
{
Schema::create('services', function (Blueprint $table) {
$table->increments('id');
$table->string('type')->nullable(false);
$table->boolean('active')->default(0); // Inactive by default
$table->text('properties')->nullable(true);
$table->string('type');
$table->boolean('active');
$table->text('properties');
$table->timestamps();
$table->index('active');
});
}
@@ -16,7 +16,7 @@ class CreateSettingsTable extends Migration
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('value')->nullable()->default(null);
$table->longText('value');
$table->timestamps();
});
}
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubscribersTable extends Migration
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
@@ -13,9 +13,9 @@ class CreateSubscribersTable extends Migration
*/
public function up()
{
Schema::create('subscribers', function (Blueprint $table) {
Schema::create('subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->nullable(false);
$table->string('email');
$table->timestamps();
$table->softDeletes();
});
@@ -28,6 +28,6 @@ class CreateSubscribersTable extends Migration
*/
public function down()
{
Schema::drop('subscribers');
Schema::drop('subscriptions');
}
}
@@ -15,10 +15,11 @@ class CreateUsersTable extends Migration
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username', 200)->nullable(false);
$table->string('password')->nullable(false);
$table->rememberToken();
$table->string('email')->nullable()->default(null);
$table->string('username');
$table->string('password');
$table->string('remember_token')->default('');
$table->string('email');
$table->string('api_key');
$table->boolean('active')->default(1);
$table->tinyInteger('level')->default(2);
$table->timestamps();