Cachet is now a Laravel 5 app
This commit is contained in:
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
39
database/migrations/2015_01_05_202826_CreateMetricsTable.php
Normal file
39
database/migrations/2015_01_05_202826_CreateMetricsTable.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
44
database/migrations/2015_01_05_203341_CreateUsersTable.php
Normal file
44
database/migrations/2015_01_05_203341_CreateUsersTable.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
35
database/migrations/2015_01_16_083825_CreateTagsTable.php
Normal file
35
database/migrations/2015_01_16_083825_CreateTagsTable.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
60
database/seeds/ComponentTableSeeder.php
Normal file
60
database/seeds/ComponentTableSeeder.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
database/seeds/DatabaseSeeder.php
Normal file
22
database/seeds/DatabaseSeeder.php
Normal 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');
|
||||
}
|
||||
}
|
||||
58
database/seeds/IncidentTableSeeder.php
Normal file
58
database/seeds/IncidentTableSeeder.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
database/seeds/SettingsTableSeeder.php
Normal file
59
database/seeds/SettingsTableSeeder.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
database/seeds/UsersTableSeeder.php
Normal file
34
database/seeds/UsersTableSeeder.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user