diff --git a/app/database/migrations/2015_01_05_202609_CreateIncidentsTable.php b/app/database/migrations/2015_01_05_202609_CreateIncidentsTable.php index df9d910c..0b6a0542 100644 --- a/app/database/migrations/2015_01_05_202609_CreateIncidentsTable.php +++ b/app/database/migrations/2015_01_05_202609_CreateIncidentsTable.php @@ -20,7 +20,6 @@ class CreateIncidentsTable extends Migration $table->integer('status'); $table->longText('message'); $table->integer('user_id'); - $table->timestamp('scheduled_at'); $table->timestamps(); $table->softDeletes(); diff --git a/app/database/migrations/2015_02_28_214642_UpdateIncidentsAddScheduledAt.php b/app/database/migrations/2015_02_28_214642_UpdateIncidentsAddScheduledAt.php new file mode 100644 index 00000000..4f92cda6 --- /dev/null +++ b/app/database/migrations/2015_02_28_214642_UpdateIncidentsAddScheduledAt.php @@ -0,0 +1,36 @@ +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'); + }); + } + +} diff --git a/app/database/seeds/IncidentTableSeeder.php b/app/database/seeds/IncidentTableSeeder.php index 2391e50a..404055ee 100644 --- a/app/database/seeds/IncidentTableSeeder.php +++ b/app/database/seeds/IncidentTableSeeder.php @@ -22,7 +22,7 @@ class IncidentTableSeeder extends Seeder "status" => 4, "component_id" => 0, "user_id" => 1, - "scheduled_at" => "0000-00-00 00:00:00", + "scheduled_at" => null, ], [ "name" => "Monitoring the fix", @@ -30,7 +30,7 @@ class IncidentTableSeeder extends Seeder "status" => 3, "component_id" => 0, "user_id" => 1, - "scheduled_at" => "0000-00-00 00:00:00", + "scheduled_at" => null, ], [ "name" => "Update", @@ -38,14 +38,14 @@ class IncidentTableSeeder extends Seeder "status" => 2, "component_id" => 0, "user_id" => 1, - "scheduled_at" => "0000-00-00 00:00:00", + "scheduled_at" => null, ], [ "name" => "Test Incident", "message" => "Something went wrong, oh noes.", "component_id" => 0, "user_id" => 1, - "scheduled_at" => "0000-00-00 00:00:00", + "scheduled_at" => null, ], ]; diff --git a/src/Models/Incident.php b/src/Models/Incident.php index 7906f40d..676bb7da 100644 --- a/src/Models/Incident.php +++ b/src/Models/Incident.php @@ -81,7 +81,7 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa public function scopeNotScheduled($query) { return $query->where(function ($query) { - return $query->where('scheduled_at', '0000-00-00 00:00:00')->orWhereRaw('scheduled_at <= NOW()'); + return $query->whereNull('scheduled_at')->orWhereRaw('scheduled_at <= NOW()'); }); } @@ -124,7 +124,7 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa */ public function getIsScheduledAttribute() { - return $this->getOriginal('scheduled_at') != '0000-00-00 00:00:00'; + return $this->getOriginal('scheduled_at'); } /**