New migration and code cleanup.

This commit is contained in:
James Cole
2014-11-13 07:25:47 +01:00
parent 71d174d765
commit 2597633b0e
26 changed files with 299 additions and 318 deletions

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateUsersTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
/**
* Run the migrations.
*
@@ -33,14 +43,4 @@ class CreateUsersTable extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}

View File

@@ -29,14 +29,14 @@ class CreateAccountTypesTable extends Migration
public function up()
{
Schema::create(
'account_types', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('type', 50);
$table->boolean('editable');
'account_types', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('type', 50);
$table->boolean('editable');
$table->unique('type');
}
$table->unique('type');
}
);
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateAccountsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('accounts');
}
/**
* Run the migrations.
*
@@ -28,28 +38,14 @@ class CreateAccountsTable extends Migration
$table->boolean('active');
// connect accounts to users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// connect accounts to account_types
$table->foreign('account_type_id')
->references('id')->on('account_types')
->onDelete('cascade');
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
$table->unique(['user_id', 'account_type_id', 'name']);
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('accounts');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateComponentsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('components');
}
/**
* Run the migrations.
*
@@ -27,9 +37,7 @@ class CreateComponentsTable extends Migration
$table->string('class', 20);
// connect components to users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->unique(['user_id', 'class', 'name']);
}
@@ -37,14 +45,4 @@ class CreateComponentsTable extends Migration
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('components');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreatePiggybanksTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybanks');
}
/**
* Run the migrations.
*
@@ -37,23 +47,11 @@ class CreatePiggybanksTable extends Migration
$table->integer('order')->unsigned();
// connect account to piggybank.
$table->foreign('account_id')
->references('id')->on('accounts')
->onDelete('cascade');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->unique(['account_id', 'name']);
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybanks');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateTransactionCurrenciesTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_currencies');
}
/**
* Run the migrations.
*
@@ -27,14 +37,4 @@ class CreateTransactionCurrenciesTable extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_currencies');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateTransactionTypesTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_types');
}
/**
* Run the migrations.
*
@@ -27,14 +37,4 @@ class CreateTransactionTypesTable extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_types');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateRecurringTransactionsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('recurring_transactions');
}
/**
* Run the migrations.
*
@@ -41,14 +51,4 @@ class CreateRecurringTransactionsTable extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('recurring_transactions');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateTransactionJournalsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_journals');
}
/**
* Run the migrations.
*
@@ -31,36 +41,18 @@ class CreateTransactionJournalsTable extends Migration
$table->date('date');
// connect transaction journals to transaction types
$table->foreign('transaction_type_id')
->references('id')->on('transaction_types')
->onDelete('cascade');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
// connect transaction journals to recurring transactions
$table->foreign('recurring_transaction_id')
->references('id')->on('recurring_transactions')
->onDelete('set null');
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('set null');
// connect transaction journals to transaction currencies
$table->foreign('transaction_currency_id')
->references('id')->on('transaction_currencies')
->onDelete('cascade');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
// connect users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transaction_journals');
}
}

View File

@@ -39,19 +39,13 @@ class CreateTransactionsTable extends Migration
$table->decimal('amount', 10, 2);
// connect transactions to transaction journals
$table->foreign('transaction_journal_id')
->references('id')->on('transaction_journals')
->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
// connect piggy banks
$table->foreign('piggybank_id')
->references('id')->on('piggybanks')
->onDelete('set null');
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('set null');
// connect account id:
$table->foreign('account_id')
->references('id')->on('accounts')
->onDelete('cascade');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateComponentTransactionTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_transaction');
}
/**
* Run the migrations.
*
@@ -25,26 +35,12 @@ class CreateComponentTransactionTable extends Migration
$table->integer('transaction_id')->unsigned();
// connect to components
$table->foreign('component_id')
->references('id')->on('components')
->onDelete('cascade');
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// connect to transactions
$table->foreign('transaction_id')
->references('id')->on('transactions')
->onDelete('cascade');
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_transaction');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateComponentTransactionJournalTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_transaction_journal');
}
/**
* Run the migrations.
*
@@ -25,26 +35,12 @@ class CreateComponentTransactionJournalTable extends Migration
$table->integer('transaction_journal_id')->unsigned();
// link components with component_id
$table->foreign('component_id')
->references('id')->on('components')
->onDelete('cascade');
$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');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_transaction_journal');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreatePreferencesTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('preferences');
}
/**
* Run the migrations.
*
@@ -27,21 +37,9 @@ class CreatePreferencesTable extends Migration
$table->text('data');
// connect preferences to users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('preferences');
}
}

View File

@@ -10,6 +10,16 @@ use Illuminate\Database\Migrations\Migration;
class CreateSessionTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('sessions');
}
/**
* Run the migrations.
*
@@ -26,14 +36,4 @@ class CreateSessionTable extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('sessions');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateLimitsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('limits');
}
/**
* Run the migrations.
*
@@ -31,21 +41,9 @@ class CreateLimitsTable extends Migration
$table->unique(['component_id', 'startdate', 'repeat_freq']);
// connect component
$table->foreign('component_id')
->references('id')->on('components')
->onDelete('cascade');
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('limits');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreateLimitRepeatTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('limit_repetitions');
}
/**
* Run the migrations.
*
@@ -30,21 +40,9 @@ class CreateLimitRepeatTable extends Migration
$table->unique(['limit_id', 'startdate', 'enddate']);
// connect limit
$table->foreign('limit_id')
->references('id')->on('limits')
->onDelete('cascade');
$table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('limit_repetitions');
}
}

View File

@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;
class RecurringTransactionsToComponents extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_recurring_transaction');
}
/**
* Run the migrations.
*
@@ -26,26 +36,12 @@ class RecurringTransactionsToComponents extends Migration
$table->boolean('optional');
// link components with component_id
$table->foreign('component_id')
->references('id')->on('components')
->onDelete('cascade');
$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');
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('component_recurring_transaction');
}
}

View File

@@ -6,6 +6,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreatePiggyInstance extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybank_repetitions');
}
/**
* Run the migrations.
*
@@ -25,21 +35,9 @@ class CreatePiggyInstance extends Migration
$table->unique(['piggybank_id', 'startdate', 'targetdate']);
// connect instance to piggybank.
$table->foreign('piggybank_id')
->references('id')->on('piggybanks')
->onDelete('cascade');
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybank_repetitions');
}
}

View File

@@ -6,6 +6,16 @@ use Illuminate\Database\Schema\Blueprint;
class CreatePiggyEvents extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybank_events');
}
/**
* Run the migrations.
*
@@ -22,21 +32,9 @@ class CreatePiggyEvents extends Migration
$table->decimal('amount', 10, 2);
// connect instance to piggybank.
$table->foreign('piggybank_id')
->references('id')->on('piggybanks')
->onDelete('cascade');
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('piggybank_events');
}
}

View File

@@ -33,9 +33,7 @@ class CreateRemindersTable extends Migration
$table->boolean('active');
// connect reminders to users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}

View File

@@ -1,41 +1,41 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateImportmapsTable extends Migration {
class CreateImportmapsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('importmaps', function(Blueprint $table)
{
$table->increments('id');
$table->timestamps();
$table->integer('user_id')->unsigned();
$table->string('file',500);
$table->integer('totaljobs')->unsigned();
$table->integer('jobsdone')->unsigned();
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('importmaps');
}
// connect maps to users
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
});
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(
'importmaps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id')->unsigned();
$table->string('file', 500);
$table->integer('totaljobs')->unsigned();
$table->integer('jobsdone')->unsigned();
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('importmaps');
}
// connect maps to users
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
}

View File

@@ -1,11 +1,21 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateImportentriesTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('importentries');
}
/**
* Run the migrations.
*
@@ -23,21 +33,9 @@ class CreateImportentriesTable extends Migration
$table->integer('new')->unsigned();
// connect import map.
$table->foreign('importmap_id')
->references('id')->on('importmaps')
->onDelete('cascade');
$table->foreign('importmap_id')->references('id')->on('importmaps')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('importentries');
}
}

View File

@@ -23,13 +23,15 @@ class CreateFailedJobsTable extends Migration
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->increments('id');
$table->text('connection');
$table->text('queue');
$table->text('payload');
$table->timestamp('failed_at');
});
Schema::create(
'failed_jobs', function (Blueprint $table) {
$table->increments('id');
$table->text('connection');
$table->text('queue');
$table->text('payload');
$table->timestamp('failed_at');
}
);
}
}

View File

@@ -1,11 +1,22 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAccountMeta extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('account_meta');
}
/**
* Run the migrations.
*
@@ -27,15 +38,4 @@ class CreateAccountMeta extends Migration
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('account_meta');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
class ExpandRemindersTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table(
'reminders', function ($table) {
$table->string('title');
$table->text('data');
}
);
}
}

View File

@@ -10,13 +10,7 @@ class DefaultUserSeeder extends Seeder
DB::table('users')->delete();
User::create(
[
'email' => 'thegrumpydictator@gmail.com',
'password' => 'sander',
'reset' => null,
'remember_token' => null,
'migrated' => 0
]
['email' => 'thegrumpydictator@gmail.com', 'password' => 'sander', 'reset' => null, 'remember_token' => null, 'migrated' => 0]
);
}