From 44e76f951870e18b4869f82434367a9bd963cf03 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 12 Jan 2016 20:56:43 +0100 Subject: [PATCH] Cleanup rule migration. --- .../2016_01_11_193428_changes_for_v370.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/database/migrations/2016_01_11_193428_changes_for_v370.php b/database/migrations/2016_01_11_193428_changes_for_v370.php index 542263f947..776113c508 100644 --- a/database/migrations/2016_01_11_193428_changes_for_v370.php +++ b/database/migrations/2016_01_11_193428_changes_for_v370.php @@ -52,11 +52,13 @@ class ChangesForV370 extends Migration $table->integer('user_id')->unsigned(); $table->integer('rule_group_id')->unsigned(); $table->unsignedSmallInteger('order'); - $table->string('title', 255); - $table->text('description'); $table->unsignedTinyInteger('active')->default(1); $table->unsignedTinyInteger('stop_processing')->default(0); + $table->string('title', 255); + $table->text('description'); + + // connect rules to users $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); @@ -76,13 +78,13 @@ class ChangesForV370 extends Migration $table->timestamps(); $table->integer('rule_id')->unsigned(); $table->unsignedSmallInteger('order'); - $table->string('title', 2048); + $table->unsignedTinyInteger('active')->default(1); + $table->unsignedTinyInteger('stop_processing')->default(0); $table->string('trigger_type', 50); $table->string('trigger_value', 255); - $table->unsignedTinyInteger('active')->default(1); - $table->unsignedTinyInteger('stop_processing')->default(0); + // order must be unique for rule triggers: $table->unique(['rule_id', 'order']); @@ -99,7 +101,6 @@ class ChangesForV370 extends Migration $table->timestamps(); $table->integer('rule_id')->unsigned(); $table->unsignedSmallInteger('order'); - $table->unsignedTinyInteger('active')->default(1); $table->unsignedTinyInteger('stop_processing')->default(0); @@ -107,6 +108,10 @@ class ChangesForV370 extends Migration $table->string('action', 50); $table->string('action_value', 255); + + + + // connect rule actions to rules $table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');