|
|
|
@@ -3,8 +3,46 @@
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class CreateMainTables
|
|
|
|
|
*/
|
|
|
|
|
class CreateMainTables extends Migration
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*/
|
|
|
|
|
public function down()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
Schema::drop('account_meta');
|
|
|
|
|
Schema::drop('piggy_bank_repetitions');
|
|
|
|
|
Schema::drop('attachments');
|
|
|
|
|
Schema::drop('limit_repetitions');
|
|
|
|
|
Schema::drop('budget_limits');
|
|
|
|
|
Schema::drop('export_jobs');
|
|
|
|
|
Schema::drop('preferences');
|
|
|
|
|
Schema::drop('role_user');
|
|
|
|
|
Schema::drop('rule_actions');
|
|
|
|
|
Schema::drop('rule_triggers');
|
|
|
|
|
Schema::drop('rules');
|
|
|
|
|
Schema::drop('rule_groups');
|
|
|
|
|
Schema::drop('category_transaction');
|
|
|
|
|
Schema::drop('budget_transaction');
|
|
|
|
|
Schema::drop('transactions');
|
|
|
|
|
Schema::drop('piggy_bank_events');
|
|
|
|
|
Schema::drop('piggy_banks');
|
|
|
|
|
Schema::drop('accounts');
|
|
|
|
|
Schema::drop('category_transaction_journal');
|
|
|
|
|
Schema::drop('budget_transaction_journal');
|
|
|
|
|
Schema::drop('categories');
|
|
|
|
|
Schema::drop('budgets');
|
|
|
|
|
Schema::drop('tag_transaction_journal');
|
|
|
|
|
Schema::drop('tags');
|
|
|
|
|
Schema::drop('journal_meta');
|
|
|
|
|
Schema::drop('transaction_journals');
|
|
|
|
|
Schema::drop('bills');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*/
|
|
|
|
@@ -22,44 +60,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$this->createPreferencesTable();
|
|
|
|
|
$this->createRoleTable();
|
|
|
|
|
$this->createRuleTables();
|
|
|
|
|
// $this->createTagsTable();
|
|
|
|
|
// $this->createTransactionTables();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*/
|
|
|
|
|
public function down()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
Schema::drop('account_meta');
|
|
|
|
|
Schema::drop('accounts');
|
|
|
|
|
|
|
|
|
|
Schema::drop('piggy_bank_repetitions');
|
|
|
|
|
Schema::drop('piggy_banks');
|
|
|
|
|
|
|
|
|
|
Schema::drop('attachments');
|
|
|
|
|
|
|
|
|
|
Schema::drop('bills');
|
|
|
|
|
|
|
|
|
|
Schema::drop('limit_repetitions');
|
|
|
|
|
Schema::drop('budget_limits');
|
|
|
|
|
Schema::drop('budgets');
|
|
|
|
|
|
|
|
|
|
Schema::drop('categories');
|
|
|
|
|
|
|
|
|
|
Schema::drop('export_jobs');
|
|
|
|
|
|
|
|
|
|
Schema::drop('preferences');
|
|
|
|
|
|
|
|
|
|
Schema::drop('role_user');
|
|
|
|
|
|
|
|
|
|
Schema::drop('rule_actions');
|
|
|
|
|
Schema::drop('rule_triggers');
|
|
|
|
|
Schema::drop('rules');
|
|
|
|
|
Schema::drop('rule_groups');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->createTagsTable();
|
|
|
|
|
$this->createTransactionTables();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -79,8 +81,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->decimal('virtual_balance', 10, 4);
|
|
|
|
|
$table->string('iban', 255);
|
|
|
|
|
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('encrypted', false, true)->default(0);
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('encrypted')->default(0);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -118,7 +120,7 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
$table->integer('user_id', false, true);
|
|
|
|
|
$table->integer('attachable_id', false, true);
|
|
|
|
|
$table->string('attachable_name', 255);
|
|
|
|
|
$table->string('attachable_type', 255);
|
|
|
|
|
$table->string('md5', 32);
|
|
|
|
|
$table->string('filename', 1024);
|
|
|
|
|
$table->string('title', 1024);
|
|
|
|
@@ -126,7 +128,7 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->text('notes');
|
|
|
|
|
$table->string('mime', 200);
|
|
|
|
|
$table->integer('size', false, true);
|
|
|
|
|
$table->tinyInteger('uploaded', false, true)->default(1);
|
|
|
|
|
$table->boolean('uploaded')->default(1);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -153,9 +155,10 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->date('date');
|
|
|
|
|
$table->string('repeat_freq', 30);
|
|
|
|
|
$table->smallInteger('skip', false, true)->default(0);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('name_encrypted', false, true)->default(0);
|
|
|
|
|
$table->tinyInteger('match_encrypted', false, true)->default(0);
|
|
|
|
|
$table->boolean('automatch')->default(1);
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('name_encrypted')->default(0);
|
|
|
|
|
$table->boolean('match_encrypted')->default(0);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -176,8 +179,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
$table->integer('user_id', false, true);
|
|
|
|
|
$table->string('name', 1024);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('encrypted', false, true)->default(0);
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('encrypted')->default(0);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -196,7 +199,7 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->date('startdate');
|
|
|
|
|
$table->decimal('amount', 10, 4);
|
|
|
|
|
$table->string('repeat_freq', 30);
|
|
|
|
|
$table->tinyInteger('repeats', false, true)->default(0);
|
|
|
|
|
$table->boolean('repeats')->default(0);
|
|
|
|
|
|
|
|
|
|
// link budget id to budgets table
|
|
|
|
|
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
|
|
|
@@ -232,7 +235,7 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
$table->integer('user_id', false, true);
|
|
|
|
|
$table->string('name', 1024);
|
|
|
|
|
$table->tinyInteger('encrypted', false, true)->default(0);
|
|
|
|
|
$table->boolean('encrypted')->default(0);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -275,7 +278,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->date('startdate');
|
|
|
|
|
$table->date('targetdate');
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(0);
|
|
|
|
|
$table->boolean('active')->default(0);
|
|
|
|
|
$table->boolean('encrypted')->default(1);
|
|
|
|
|
|
|
|
|
|
// link to account_id to accounts
|
|
|
|
|
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
|
|
|
@@ -293,7 +297,6 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->date('targetdate');
|
|
|
|
|
$table->decimal('currentamount', 10, 4);
|
|
|
|
|
|
|
|
|
|
// link to account_id to accounts
|
|
|
|
|
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -313,7 +316,6 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->string('name', 1024);
|
|
|
|
|
$table->text('data');
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -352,7 +354,7 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->string('title', 255);
|
|
|
|
|
$table->text('description');
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -370,8 +372,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->string('title', 255);
|
|
|
|
|
$table->text('description');
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('stop_processing', false, true)->default(0);
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('stop_processing')->default(0);
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
@@ -392,9 +394,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->string('action_value', 255);
|
|
|
|
|
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('stop_processing', false, true)->default(0);
|
|
|
|
|
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('stop_processing')->default(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// link rule id to rules table
|
|
|
|
@@ -413,9 +414,8 @@ class CreateMainTables extends Migration
|
|
|
|
|
$table->string('trigger_value', 255);
|
|
|
|
|
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->tinyInteger('active', false, true)->default(1);
|
|
|
|
|
$table->tinyInteger('stop_processing', false, true)->default(0);
|
|
|
|
|
|
|
|
|
|
$table->boolean('active')->default(1);
|
|
|
|
|
$table->boolean('stop_processing')->default(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// link rule id to rules table
|
|
|
|
@@ -424,4 +424,189 @@ class CreateMainTables extends Migration
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
private function createTagsTable()
|
|
|
|
|
{
|
|
|
|
|
if (!Schema::hasTable('tags')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'tags', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
$table->integer('user_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->string('tag', 1024);
|
|
|
|
|
$table->string('tagMode', 1024);
|
|
|
|
|
$table->date('date');
|
|
|
|
|
$table->text('description');
|
|
|
|
|
$table->decimal('latitude', 18, 12);
|
|
|
|
|
$table->decimal('longitude', 18, 12);
|
|
|
|
|
$table->boolean('zoomLevel');
|
|
|
|
|
|
|
|
|
|
// link user id to users table
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createTransactionTables()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('transaction_journals')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'transaction_journals', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
|
|
|
|
|
$table->integer('user_id', false, true);
|
|
|
|
|
$table->integer('transaction_type_id', false, true);
|
|
|
|
|
$table->integer('bill_id', false, true)->nullable();
|
|
|
|
|
$table->integer('transaction_currency_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->string('description', 1024);
|
|
|
|
|
|
|
|
|
|
$table->date('date');
|
|
|
|
|
$table->date('interest_date')->nullable();
|
|
|
|
|
$table->date('book_date')->nullable();
|
|
|
|
|
$table->date('process_date')->nullable();
|
|
|
|
|
|
|
|
|
|
$table->integer('order', false, true);
|
|
|
|
|
$table->integer('tag_count', false, true);
|
|
|
|
|
|
|
|
|
|
$table->boolean('encrypted')->default(1);
|
|
|
|
|
$table->boolean('completed')->default(1);
|
|
|
|
|
|
|
|
|
|
// links to other tables:
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
|
|
|
|
$table->foreign('bill_id')->references('id')->on('bills')->onDelete('set null');
|
|
|
|
|
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('journal_meta')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'journal_meta', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->integer('transaction_journal_id', false, true);
|
|
|
|
|
$table->string('name', 255);
|
|
|
|
|
$table->text('data');
|
|
|
|
|
$table->string('hash', 64);
|
|
|
|
|
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('tag_transaction_journal')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'tag_transaction_journal', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->integer('tag_id', false, true);
|
|
|
|
|
$table->integer('transaction_journal_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('budget_transaction_journal')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'budget_transaction_journal', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->integer('budget_id', false, true);
|
|
|
|
|
$table->integer('transaction_journal_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('category_transaction_journal')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'category_transaction_journal', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->integer('category_id', false, true);
|
|
|
|
|
$table->integer('transaction_journal_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('piggy_bank_events')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'piggy_bank_events', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->integer('piggy_bank_id', false, true);
|
|
|
|
|
$table->integer('transaction_journal_id', false, true)->nullable();
|
|
|
|
|
$table->date('date');
|
|
|
|
|
$table->decimal('amount', 10, 4);
|
|
|
|
|
|
|
|
|
|
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('transactions')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'transactions', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->softDeletes();
|
|
|
|
|
$table->integer('account_id', false, true);
|
|
|
|
|
$table->integer('transaction_journal_id', false, true);
|
|
|
|
|
$table->string('description', 255);
|
|
|
|
|
$table->decimal('amount', 10, 4);
|
|
|
|
|
|
|
|
|
|
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('budget_transaction')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'budget_transaction', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->integer('budget_id', false, true);
|
|
|
|
|
$table->integer('transaction_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Schema::hasTable('')) {
|
|
|
|
|
Schema::create(
|
|
|
|
|
'category_transaction', function (Blueprint $table) {
|
|
|
|
|
$table->increments('id');
|
|
|
|
|
$table->integer('category_id', false, true);
|
|
|
|
|
$table->integer('transaction_id', false, true);
|
|
|
|
|
|
|
|
|
|
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
|
|
|
|
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|