firefly-iii/database/migrations/2016_06_16_000002_create_main_tables.php

632 lines
26 KiB
PHP
Raw Normal View History

2016-06-17 07:06:38 -05:00
<?php
2017-12-10 02:02:26 -06:00
/**
* 2016_06_16_000002_create_main_tables.php
2020-03-17 11:06:30 -05:00
* Copyright (c) 2019 james@firefly-iii.org.
2017-12-10 02:02:26 -06:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2017-12-10 02:02:26 -06:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-12-10 02:02:26 -06:00
*
* This program is distributed in the hope that it will be useful,
2017-12-10 02:02:26 -06:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-12-10 02:02:26 -06:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2017-12-10 02:02:26 -06:00
*/
2017-03-25 07:41:17 -05:00
declare(strict_types=1);
2016-06-17 07:06:38 -05:00
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
2016-06-18 00:36:15 -05:00
/**
2020-03-17 11:06:30 -05:00
* Class CreateMainTables.
2021-03-11 23:17:50 -06:00
*
2020-10-27 00:53:47 -05:00
* @codeCoverageIgnore
2016-06-18 00:36:15 -05:00
*/
2016-06-17 07:06:38 -05:00
class CreateMainTables extends Migration
{
/**
* Reverse the migrations.
*/
public function down(): void
2016-06-17 07:06:38 -05:00
{
Schema::drop('account_meta');
Schema::drop('piggy_bank_repetitions');
Schema::drop('attachments');
Schema::drop('limit_repetitions');
Schema::drop('budget_limits');
Schema::drop('export_jobs');
2016-06-24 07:24:34 -05:00
Schema::drop('import_jobs');
2016-06-17 07:06:38 -05:00
Schema::drop('preferences');
Schema::drop('role_user');
Schema::drop('rule_actions');
Schema::drop('rule_triggers');
Schema::drop('rules');
Schema::drop('rule_groups');
2016-06-18 00:36:15 -05:00
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');
}
2016-06-17 07:06:38 -05:00
2016-06-18 00:36:15 -05:00
/**
* Run the migrations.
*
* @SuppressWarnings(PHPMD.ShortMethodName)
2016-06-18 00:36:15 -05:00
*/
public function up(): void
2016-06-18 00:36:15 -05:00
{
$this->createAccountTables();
$this->createPiggyBanksTable();
$this->createAttachmentsTable();
$this->createBillsTable();
$this->createBudgetTables();
$this->createCategoriesTable();
$this->createExportJobsTable();
$this->createPreferencesTable();
$this->createRoleTable();
$this->createRuleTables();
$this->createTagsTable();
$this->createTransactionTables();
2016-06-17 07:06:38 -05:00
}
private function createAccountTables(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('accounts')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'accounts',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('account_type_id', false, true);
$table->string('name', 1024);
2021-03-27 14:01:28 -05:00
$table->decimal('virtual_balance', 36, 24)->nullable();
2017-11-15 03:53:17 -06:00
$table->string('iban', 255)->nullable();
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('account_meta')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'account_meta',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('account_id', false, true);
$table->string('name');
$table->text('data');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
2021-03-11 23:17:50 -06:00
private function createPiggyBanksTable(): void
{
if (!Schema::hasTable('piggy_banks')) {
Schema::create(
'piggy_banks',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->string('name', 1024);
2021-03-27 14:01:28 -05:00
$table->decimal('targetamount', 36, 24);
2021-03-11 23:17:50 -06:00
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(0);
$table->boolean('encrypted')->default(1);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
}
if (!Schema::hasTable('piggy_bank_repetitions')) {
Schema::create(
'piggy_bank_repetitions',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
2021-03-27 14:01:28 -05:00
$table->decimal('currentamount', 36, 24);
2021-03-11 23:17:50 -06:00
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
}
);
}
}
private function createAttachmentsTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('attachments')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'attachments',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('attachable_id', false, true);
$table->string('attachable_type', 255);
2020-04-10 23:42:21 -05:00
$table->string('md5', 128);
2017-11-15 03:53:17 -06:00
$table->string('filename', 1024);
$table->string('title', 1024)->nullable();
$table->text('description')->nullable();
$table->text('notes')->nullable();
$table->string('mime', 1024);
$table->integer('size', false, true);
$table->boolean('uploaded')->default(1);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
private function createBillsTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('bills')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'bills',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->string('match', 1024);
2021-03-27 14:01:28 -05:00
$table->decimal('amount_min', 36, 24);
$table->decimal('amount_max', 36, 24);
2017-11-15 03:53:17 -06:00
$table->date('date');
$table->string('repeat_freq', 30);
$table->smallInteger('skip', 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');
}
2016-06-17 07:06:38 -05:00
);
}
}
2016-06-24 07:24:34 -05:00
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
2016-06-24 07:24:34 -05:00
*/
private function createBudgetTables(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('budgets')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'budgets',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('budget_limits')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'budget_limits',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('budget_id', false, true);
$table->date('startdate');
2021-03-27 14:01:28 -05:00
$table->decimal('amount', 36, 24);
2017-11-15 03:53:17 -06:00
$table->string('repeat_freq', 30);
$table->boolean('repeats')->default(0);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('limit_repetitions')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'limit_repetitions',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('budget_limit_id', false, true);
$table->date('startdate');
$table->date('enddate');
2021-03-27 14:01:28 -05:00
$table->decimal('amount', 36, 24);
2017-11-15 03:53:17 -06:00
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
private function createCategoriesTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('categories')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'categories',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('encrypted')->default(0);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
private function createExportJobsTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('export_jobs')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'export_jobs',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('user_id', false, true);
$table->string('key', 12);
$table->string('status', 255);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
2016-06-24 07:24:34 -05:00
if (!Schema::hasTable('import_jobs')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'import_jobs',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('user_id')->unsigned();
$table->string('key', 12)->unique();
$table->string('file_type', 12);
$table->string('status', 45);
$table->text('configuration')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-24 07:24:34 -05:00
);
}
2016-06-17 07:06:38 -05:00
}
private function createPreferencesTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('preferences')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'preferences',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->text('data');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
private function createRoleTable(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('role_user')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'role_user',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->integer('user_id', false, true);
$table->integer('role_id', false, true);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->primary(['user_id', 'role_id']);
}
2016-06-17 07:06:38 -05:00
);
}
}
2016-06-24 07:24:34 -05:00
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
2016-06-24 07:24:34 -05:00
*/
private function createRuleTables(): void
2016-06-17 07:06:38 -05:00
{
if (!Schema::hasTable('rule_groups')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'rule_groups',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('rules')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'rules',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('rule_group_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', 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');
// link rule group id to rule group table
$table->foreign('rule_group_id')->references('id')->on('rule_groups')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('rule_actions')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'rule_actions',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->string('action_type', 50);
$table->string('action_value', 255);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
if (!Schema::hasTable('rule_triggers')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'rule_triggers',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->string('trigger_type', 50);
$table->string('trigger_value', 255);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
2016-06-17 07:06:38 -05:00
2017-11-15 03:53:17 -06:00
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
}
2016-06-17 07:06:38 -05:00
);
}
}
2016-06-18 00:36:15 -05:00
private function createTagsTable(): void
2016-06-18 00:36:15 -05:00
{
if (!Schema::hasTable('tags')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'tags',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('tag', 1024);
$table->string('tagMode', 1024);
$table->date('date')->nullable();
$table->text('description')->nullable();
2021-03-27 14:01:28 -05:00
$table->decimal('latitude', 36, 24)->nullable();
$table->decimal('longitude', 36, 24)->nullable();
2017-11-15 03:53:17 -06:00
$table->smallInteger('zoomLevel', false, true)->nullable();
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
2016-06-18 00:36:15 -05:00
);
}
}
2016-06-24 07:24:34 -05:00
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
* @SuppressWarnings(PHPMD.NPathComplexity) // cannot be helped
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
2016-06-24 07:24:34 -05:00
*/
private function createTransactionTables(): void
2016-06-18 00:36:15 -05:00
{
if (!Schema::hasTable('transaction_journals')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'transaction_journals',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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)->default(0);
$table->integer('tag_count', false, true);
$table->boolean('encrypted')->default(1);
$table->boolean('completed')->default(1);
$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(
2017-11-15 03:53:17 -06:00
'journal_meta',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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(
2017-11-15 03:53:17 -06:00
'tag_transaction_journal',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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');
2017-11-15 08:30:15 -06:00
// unique combi:
$table->unique(['tag_id', 'transaction_journal_id']);
2017-11-15 03:53:17 -06:00
}
);
}
if (!Schema::hasTable('budget_transaction_journal')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'budget_transaction_journal',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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(
2017-11-15 03:53:17 -06:00
'category_transaction_journal',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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');
}
);
}
2016-06-18 00:36:15 -05:00
if (!Schema::hasTable('piggy_bank_events')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'piggy_bank_events',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->integer('transaction_journal_id', false, true)->nullable();
$table->date('date');
2021-03-27 14:01:28 -05:00
$table->decimal('amount', 36, 24);
2017-11-15 03:53:17 -06:00
$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');
}
2016-06-18 00:36:15 -05:00
);
}
if (!Schema::hasTable('transactions')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'transactions',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->string('description', 1024)->nullable();
2021-03-27 14:01:28 -05:00
$table->decimal('amount', 36, 24);
2017-11-15 03:53:17 -06:00
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
2016-06-18 00:36:15 -05:00
);
}
if (!Schema::hasTable('budget_transaction')) {
Schema::create(
2017-11-15 03:53:17 -06:00
'budget_transaction',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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');
}
2016-06-18 00:36:15 -05:00
);
}
if (!Schema::hasTable('category_transaction')) {
2016-06-18 00:36:15 -05:00
Schema::create(
2017-11-15 03:53:17 -06:00
'category_transaction',
2020-03-17 11:06:30 -05:00
static function (Blueprint $table) {
2017-11-15 03:53:17 -06:00
$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');
}
2016-06-18 00:36:15 -05:00
);
}
}
2016-06-17 07:06:38 -05:00
}