Code cleanup.

This commit is contained in:
James Cole
2014-12-13 21:59:02 +01:00
parent c77b43458e
commit 3cfa3f3b27
67 changed files with 651 additions and 177 deletions

View File

@@ -30,19 +30,19 @@ class CreateComponentTransactionJournalTable extends Migration
{
Schema::create(
'component_transaction_journal', function (Blueprint $table) {
$table->increments('id');
$table->integer('component_id')->unsigned();
$table->integer('transaction_journal_id')->unsigned();
$table->increments('id');
$table->integer('component_id')->unsigned();
$table->integer('transaction_journal_id')->unsigned();
// link components with component_id
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// link components with component_id
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// link transaction journals with transaction_journal_id
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
// link transaction journals with transaction_journal_id
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
// combo must be unique:
$table->unique(['component_id', 'transaction_journal_id'],'cid_tjid_unique');
}
// combo must be unique:
$table->unique(['component_id', 'transaction_journal_id'], 'cid_tjid_unique');
}
);
}

View File

@@ -30,21 +30,21 @@ class CreateComponentRecurringTransactionTable extends Migration
{
Schema::create(
'component_recurring_transaction', function (Blueprint $table) {
$table->increments('id');
$table->integer('component_id')->unsigned();
$table->integer('recurring_transaction_id')->unsigned();
$table->boolean('optional');
$table->increments('id');
$table->integer('component_id')->unsigned();
$table->integer('recurring_transaction_id')->unsigned();
$table->boolean('optional');
// link components with component_id
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// link components with component_id
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// link transaction journals with transaction_journal_id
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
// link transaction journals with transaction_journal_id
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
// component and recurring transaction must be unique.
$table->unique(['component_id','recurring_transaction_id'],'cid_rtid_unique');
// component and recurring transaction must be unique.
$table->unique(['component_id', 'recurring_transaction_id'], 'cid_rtid_unique');
}
}
);
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
/**
* Class ChangesForV321
*/
class ChangesForV321 extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::update(DB::raw('RENAME TABLE `budget_limits` TO `limits`;'));
DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `budget_limit_id` `limit_id` INT UNSIGNED NOT NULL'));
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::update(DB::raw('RENAME TABLE `limits` TO `budget_limits`;'));
DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `limit_id` `budget_limit_id` INT UNSIGNED NOT NULL'));
}
}