mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Cleanup migrations.
This commit is contained in:
parent
360f286ed3
commit
727221e2cb
@ -36,8 +36,6 @@ class CreateUsersTable extends Migration
|
||||
$table->string('password', 60);
|
||||
$table->string('reset', 32)->nullable();
|
||||
$table->string('remember_token', 255)->nullable();
|
||||
$table->boolean('migrated');
|
||||
|
||||
$table->unique('email');
|
||||
}
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ class CreateAccountTypesTable extends Migration
|
||||
'account_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('type', 50);
|
||||
$table->string('type', 30);
|
||||
$table->boolean('editable');
|
||||
|
||||
$table->unique('type');
|
||||
|
@ -44,6 +44,7 @@ class CreateAccountsTable extends Migration
|
||||
// connect accounts to account_types
|
||||
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
|
||||
|
||||
// for a user, the account name must be unique.
|
||||
$table->unique(['user_id', 'account_type_id', 'name']);
|
||||
}
|
||||
);
|
||||
|
@ -40,6 +40,7 @@ class CreateComponentsTable extends Migration
|
||||
// connect components to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// for a user, the component type & name must be unique.
|
||||
$table->unique(['user_id', 'class', 'name']);
|
||||
}
|
||||
);
|
||||
|
@ -48,6 +48,8 @@ class CreatePiggybanksTable extends Migration
|
||||
|
||||
// connect account to piggybank.
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
// for an account, the name must be unique.
|
||||
$table->unique(['account_id', 'name']);
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class CreateTransactionCurrenciesTable extends Migration
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('code', 3);
|
||||
|
||||
// code must be unique.
|
||||
$table->unique(['code']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class CreateTransactionTypesTable extends Migration
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('type', 50);
|
||||
|
||||
// type must be unique.
|
||||
$table->unique(['type']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class CreateRecurringTransactionsTable extends Migration
|
||||
$table->enum('repeat_freq', ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']);
|
||||
$table->smallInteger('skip')->unsigned();
|
||||
|
||||
// connect user id to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// for a user, the name must be unique
|
||||
$table->unique(['user_id', 'name']);
|
||||
|
||||
|
||||
|
@ -41,6 +41,9 @@ class CreateTransactionJournalsTable extends Migration
|
||||
$table->boolean('completed');
|
||||
$table->date('date');
|
||||
|
||||
// connect users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// connect transaction journals to transaction types
|
||||
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
||||
|
||||
@ -50,8 +53,7 @@ class CreateTransactionJournalsTable extends Migration
|
||||
// connect transaction journals to transaction currencies
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
|
||||
// connect users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -39,14 +39,18 @@ class CreateTransactionsTable extends Migration
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->decimal('amount', 10, 2);
|
||||
|
||||
// connect transactions to transaction journals
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
// connect account id:
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
// connect piggy banks
|
||||
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('set null');
|
||||
|
||||
// connect account id:
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
// connect transactions to transaction journals
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
@ -39,6 +39,9 @@ class CreateComponentTransactionTable extends Migration
|
||||
|
||||
// connect to transactions
|
||||
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
||||
|
||||
// combo must be unique:
|
||||
$table->unique(['component_id', 'transaction_id']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ class CreateComponentTransactionJournalTable extends Migration
|
||||
|
||||
// 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');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ class CreatePreferencesTable extends Migration
|
||||
|
||||
// connect preferences to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// only one preference per name per user
|
||||
$table->unique(['user_id', 'name']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class RecurringTransactionsToComponents
|
||||
* Class CreateComponentRecurringTransactionTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class RecurringTransactionsToComponents extends Migration
|
||||
class CreateComponentRecurringTransactionTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
@ -40,6 +40,10 @@ class RecurringTransactionsToComponents extends Migration
|
||||
|
||||
// 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');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
@ -3,7 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreatePiggyInstance extends Migration
|
||||
/**
|
||||
* Class CreatePiggyInstance
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreatePiggybankRepetitionsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
@ -3,7 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreatePiggyEvents extends Migration
|
||||
/**
|
||||
* Class CreatePiggybankEventsTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreatePiggybankEventsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
@ -28,11 +33,16 @@ class CreatePiggyEvents extends Migration
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('piggybank_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned()->nullable();
|
||||
|
||||
$table->date('date');
|
||||
$table->decimal('amount', 10, 2);
|
||||
|
||||
// connect instance to piggybank.
|
||||
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
|
||||
|
||||
// connect to journal:
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
}
|
@ -3,6 +3,11 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateRemindersTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreateRemindersTable extends Migration
|
||||
{
|
||||
|
||||
@ -31,6 +36,9 @@ class CreateRemindersTable extends Migration
|
||||
$table->date('startdate');
|
||||
$table->date('enddate')->nullable();
|
||||
$table->boolean('active');
|
||||
$table->boolean('notnow')->default(0);
|
||||
$table->integer('remindersable_id')->unsigned()->nullable();
|
||||
$table->string('remindersable_type')->nullable();
|
||||
|
||||
// connect reminders to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateImportmapsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('importmaps');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
// connect maps to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'importentries', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('class', 200);
|
||||
$table->integer('importmap_id')->unsigned();
|
||||
$table->integer('old')->unsigned();
|
||||
$table->integer('new')->unsigned();
|
||||
|
||||
// connect import map.
|
||||
$table->foreign('importmap_id')->references('id')->on('importmaps')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('failed_jobs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAccountMeta extends Migration
|
||||
/**
|
||||
* Class CreateAccountMetaTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreateAccountMetaTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
@ -33,6 +38,8 @@ class CreateAccountMeta extends Migration
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
$table->unique(['account_id', 'name']);
|
||||
|
||||
|
||||
}
|
||||
);
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class ExtendPiggybankEvents extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(
|
||||
'piggybank_events', function (Blueprint $table) {
|
||||
$table->integer('transaction_journal_id')->unsigned()->nullable();
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class EventTableAdditions1 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// remove some fields:
|
||||
Schema::table(
|
||||
'reminders', function (Blueprint $table) {
|
||||
$table->boolean('notnow')->default(0);
|
||||
$table->integer('remindersable_id')->unsigned()->nullable();
|
||||
$table->string('remindersable_type')->nullable();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CacheTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'cache', function ($table) {
|
||||
$table->string('key')->unique();
|
||||
$table->text('value');
|
||||
$table->integer('expiration');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class Transactiongroups extends Migration
|
||||
/**
|
||||
* Class CreateTransactionGroupsTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreateTransactionGroupsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
@ -3,7 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class Transactiongroupsjoin extends Migration
|
||||
/**
|
||||
* Class CreateTransactionGroupTransactionJournalTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreateTransactionGroupTransactionJournalTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
@ -31,9 +36,11 @@ class Transactiongroupsjoin extends Migration
|
||||
$table->integer('transaction_group_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
|
||||
// link to foreign tables.
|
||||
$table->foreign('transaction_group_id', 'tr_grp_id')->references('id')->on('transaction_groups')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id', 'tr_trj_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
// add unique.
|
||||
$table->unique(['transaction_group_id', 'transaction_journal_id'], 'tt_joined');
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user