mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Introduce new model for future remodeling of split transactions.
This commit is contained in:
@@ -71,10 +71,6 @@ class ChangesForV475 extends Migration
|
||||
$table->boolean('apply_rules')->default(true);
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
// also separate:
|
||||
// category, budget, tags, notes, bill, piggy bank
|
||||
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
||||
}
|
||||
|
60
database/migrations/2019_01_28_193833_changes_for_v4710.php
Normal file
60
database/migrations/2019_01_28_193833_changes_for_v4710.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ChangesForV4710 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('group_journals');
|
||||
Schema::dropIfExists('transaction_groups');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!Schema::hasTable('transaction_groups')) {
|
||||
Schema::create(
|
||||
'transaction_groups', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->string('title', 1024)->nullable();
|
||||
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('group_journals')) {
|
||||
Schema::create(
|
||||
'group_journals',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('transaction_group_id', false, true);
|
||||
$table->integer('transaction_journal_id', false, true);
|
||||
|
||||
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
// unique combi:
|
||||
$table->unique(['transaction_group_id', 'transaction_journal_id'],'unique_in_group');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user