mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Migration for rules.
This commit is contained in:
parent
c38a4a15ff
commit
c1346d4c86
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV370
|
||||
@ -21,7 +22,100 @@ class ChangesForV370 extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
// new table "rule_groups"
|
||||
Schema::create(
|
||||
'rule_groups', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->string('title', 2048);
|
||||
$table->mediumText('description');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
|
||||
// connect rule groups to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// order must be unique for rule group:
|
||||
$table->unique(['user_id', 'order']);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// new table "rules":
|
||||
Schema::create(
|
||||
'rules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('rule_group_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->string('title', 2048);
|
||||
$table->mediumText('description');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
// connect rules to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// connect rules to rule groups
|
||||
$table->foreign('rule_group_id')->references('id')->on('rule_groups')->onDelete('cascade');
|
||||
|
||||
// order must be unique for rules:
|
||||
$table->unique(['user_id', 'order']);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// new table "rule_triggers"
|
||||
Schema::create(
|
||||
'rule_triggers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('rule_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->string('title', 2048);
|
||||
|
||||
$table->string('trigger_field', 2048);
|
||||
$table->string('trigger_type', 1024);
|
||||
$table->string('trigger_value', 2048);
|
||||
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
// order must be unique for rule triggers:
|
||||
$table->unique(['rule_id', 'order']);
|
||||
|
||||
// connect rule tiggers to rules
|
||||
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// new table "rule_actions"
|
||||
Schema::create(
|
||||
'rule_actions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('rule_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
$table->string('action_field', 2048);
|
||||
$table->string('action', 1024);
|
||||
$table->string('action_value', 2048);
|
||||
|
||||
// connect rule actions to rules
|
||||
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
|
||||
|
||||
// order must be unique for rule triggers:
|
||||
$table->unique(['rule_id', 'order']);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,6 +125,10 @@ class ChangesForV370 extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::drop('rule_actions');
|
||||
Schema::drop('rule_triggers');
|
||||
Schema::drop('rules');
|
||||
Schema::drop('rule_groups');
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user