Cachet is now a Laravel 5 app

This commit is contained in:
Joseph Cohen
2015-03-20 18:30:45 -06:00
parent 7cfa158e68
commit b4ac66d727
338 changed files with 4164 additions and 4114 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateComponentGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('component_groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_groups');
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateComponentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('components', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('description');
$table->text('link');
$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');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('components');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateIncidentTemplatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('incident_templates', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('slug');
$table->longText('template');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('incident_templates');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateIncidentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('incidents', function (Blueprint $table) {
$table->increments('id');
$table->integer('component_id')->default(0);
$table->string('name');
$table->integer('status');
$table->longText('message');
$table->integer('user_id');
$table->timestamps();
$table->softDeletes();
$table->index('component_id');
$table->index('status');
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('incidents');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMetricPointsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('metric_points', function (Blueprint $table) {
$table->increments('id');
$table->integer('metric_id');
$table->decimal('value', 10, 3);
$table->timestamps();
$table->index('metric_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('metric_points');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMetricsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('metrics', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('suffix');
$table->text('description');
$table->decimal('default_value', 10, 3);
$table->tinyInteger('calc_type');
$table->boolean('display_chart')->default(1);
$table->timestamps();
$table->index('display_chart');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('metrics');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateServicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('services', function (Blueprint $table) {
$table->increments('id');
$table->string('type');
$table->boolean('active');
$table->text('properties');
$table->timestamps();
$table->index('active');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('services');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->longText('value');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('settings');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->string('email');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('subscriptions');
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username');
$table->string('password');
$table->rememberToken();
$table->string('email');
$table->string('api_key');
$table->boolean('active')->default(1);
$table->tinyInteger('level')->default(2);
$table->timestamps();
$table->index('remember_token');
$table->index('active');
$table->unique('username');
$table->unique('api_key');
$table->unique('email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableUsersAdd2FA extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('google_2fa_secret')->nullable()->after('remember_token');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('google_2fa_secret');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTagsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('slug');
$table->timestamps();
$table->unique(['name', 'slug']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('tags');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateComponentTagTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('component_tag', function (Blueprint $table) {
$table->increments('id');
$table->integer('component_id');
$table->integer('tag_id');
$table->index('component_id');
$table->index('tag_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_tag');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateIncidentsAddScheduledAt extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('incidents', function (Blueprint $table) {
$table->timestamp('scheduled_at')->after('user_id')->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('incidents', function (Blueprint $table) {
$table->dropColumn('scheduled_at');
});
}
}

View File

@@ -0,0 +1,60 @@
<?php
use CachetHQ\Cachet\Models\Component;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class ComponentTableSeeder extends Seeder
{
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$defaultComponents = [
[
"name" => "API",
"description" => "Used by third-parties to connect to us",
"status" => 2,
"user_id" => 1,
"order" => 0,
"group_id" => 0,
"link" => "",
], [
"name" => "Documentation",
"description" => "Kindly powered by Readme.io",
"status" => 1,
"user_id" => 1,
"order" => 0,
"group_id" => 0,
"link" => "https://docs.cachethq.io",
], [
"name" => "Website",
"description" => "",
"status" => 1,
"user_id" => 1,
"order" => 0,
"group_id" => 0,
"link" => "https://cachethq.io",
], [
"name" => "Blog",
"description" => "The Cachet HQ blog.",
"status" => 1,
"user_id" => 1,
"order" => 0,
"group_id" => 0,
"link" => "https://blog.cachethq.io",
],
];
Component::truncate();
foreach ($defaultComponents as $component) {
Component::create($component);
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call('UsersTableSeeder');
$this->call('SettingsTableSeeder');
$this->call('IncidentTableSeeder');
$this->call('ComponentTableSeeder');
}
}

View File

@@ -0,0 +1,58 @@
<?php
use CachetHQ\Cachet\Models\Incident;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class IncidentTableSeeder extends Seeder
{
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$defaultIncidents = [
[
"name" => "Awesome",
"message" => "We totally nailed the fix.",
"status" => 4,
"component_id" => 0,
"user_id" => 1,
"scheduled_at" => null,
],
[
"name" => "Monitoring the fix",
"message" => "We're checking that our fix will first work.",
"status" => 3,
"component_id" => 0,
"user_id" => 1,
"scheduled_at" => null,
],
[
"name" => "Update",
"message" => "We've found the problem, so we're looking at it.",
"status" => 2,
"component_id" => 0,
"user_id" => 1,
"scheduled_at" => null,
],
[
"name" => "Test Incident",
"message" => "Something went wrong, oh noes.",
"component_id" => 0,
"user_id" => 1,
"scheduled_at" => null,
],
];
Incident::truncate();
foreach ($defaultIncidents as $incident) {
Incident::create($incident);
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
use CachetHQ\Cachet\Models\Setting;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class SettingsTableSeeder extends Seeder
{
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$defaultSettings = [
[
"name" => "app_name",
"value" => "Cachet Demo",
],
[
"name" => "app_domain",
"value" => "https://demo.cachethq.io",
],
[
"name" => "show_support",
"value" => "1",
],
[
"name" => "app_locale",
"value" => "en",
],
[
"name" => "app_timezone",
"value" => "Europe/London",
],
[
"name" => "app_track",
"value" => "1",
],
[
"name" => "app_incident_days",
"value" => "7",
],
[
"name" => "app_analytics",
"value" => "UA-58442674-3",
],
];
Setting::truncate();
foreach ($defaultSettings as $setting) {
Setting::create($setting);
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
use CachetHQ\Cachet\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeding.
*
* @return void
*/
public function run()
{
Model::unguard();
$users = [
[
"username" => "test",
"password" => "test123",
"email" => "test@test.com",
"level" => 1,
"api_key" => "9yMHsdioQosnyVK4iCVR",
],
];
User::truncate();
foreach ($users as $user) {
User::create($user);
}
}
}