mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
First attempt at rewriting all migrations.
This commit is contained in:
parent
ae649223d8
commit
d2733a4df0
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateUsersTable
|
||||
*/
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('email', 100)->unique();
|
||||
$table->string('password', 60);
|
||||
$table->rememberToken();
|
||||
$table->string('reset', 32)->nullable();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateAccountTypesTable
|
||||
*
|
||||
*/
|
||||
class CreateAccountTypesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('account_types');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'account_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('type', 30);
|
||||
$table->boolean('editable');
|
||||
|
||||
$table->unique('type');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateAccountsTable
|
||||
*
|
||||
*/
|
||||
class CreateAccountsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('account_type_id')->unsigned();
|
||||
$table->string('name', 100);
|
||||
$table->boolean('active');
|
||||
|
||||
// connect accounts to users
|
||||
$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');
|
||||
|
||||
// for a user, the account name must be unique.
|
||||
$table->unique(['user_id', 'account_type_id', 'name']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateComponentsTable
|
||||
*
|
||||
*/
|
||||
class CreateComponentsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('components');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'components', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('name', 50);
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('class', 20);
|
||||
|
||||
// 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']);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePiggybanksTable
|
||||
*
|
||||
*/
|
||||
class CreatePiggybanksTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('piggybanks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'piggybanks', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('account_id')->unsigned();
|
||||
$table->string('name', 100);
|
||||
$table->decimal('targetamount', 10, 2);
|
||||
$table->date('startdate')->nullable();
|
||||
$table->date('targetdate')->nullable();
|
||||
$table->boolean('repeats');
|
||||
$table->enum('rep_length', ['day', 'week', 'quarter', 'month', 'year'])->nullable();
|
||||
$table->smallInteger('rep_every')->unsigned();
|
||||
$table->smallInteger('rep_times')->unsigned()->nullable();
|
||||
$table->enum('reminder', ['day', 'week', 'quarter', 'month', 'year'])->nullable();
|
||||
$table->smallInteger('reminder_skip')->unsigned();
|
||||
$table->boolean('remind_me');
|
||||
$table->integer('order')->unsigned();
|
||||
|
||||
// connect account to piggy bank.
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
// for an account, the name must be unique.
|
||||
$table->unique(['account_id', 'name']);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateTransactionCurrenciesTable
|
||||
*
|
||||
*/
|
||||
class CreateTransactionCurrenciesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transaction_currencies');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'transaction_currencies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('code', 3);
|
||||
|
||||
// code must be unique.
|
||||
$table->unique(['code']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateTransactionTypesTable
|
||||
*
|
||||
*/
|
||||
class CreateTransactionTypesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transaction_types');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'transaction_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('type', 50);
|
||||
|
||||
// type must be unique.
|
||||
$table->unique(['type']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateRecurringTransactionsTable
|
||||
*
|
||||
*/
|
||||
class CreateRecurringTransactionsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('recurring_transactions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'recurring_transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('name', 50);
|
||||
$table->string('match', 255);
|
||||
$table->decimal('amount_min', 10, 2);
|
||||
$table->decimal('amount_max', 10, 2);
|
||||
$table->date('date');
|
||||
$table->boolean('active');
|
||||
|
||||
$table->boolean('automatch');
|
||||
$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']);
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateTransactionJournalsTable
|
||||
*
|
||||
*/
|
||||
class CreateTransactionJournalsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transaction_journals');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('transaction_type_id')->unsigned();
|
||||
$table->integer('recurring_transaction_id')->unsigned()->nullable();
|
||||
$table->integer('transaction_currency_id')->unsigned();
|
||||
$table->string('description', 255)->nullable();
|
||||
$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');
|
||||
|
||||
// connect transaction journals to recurring transactions
|
||||
$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');
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateTransactionsTable
|
||||
*
|
||||
*/
|
||||
class CreateTransactionsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transactions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('account_id')->unsigned();
|
||||
$table->integer('piggybank_id')->nullable()->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->decimal('amount', 10, 2);
|
||||
|
||||
// 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 transactions to transaction journals
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateComponentTransactionTable
|
||||
*
|
||||
*/
|
||||
class CreateComponentTransactionTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('component_transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'component_transaction', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->integer('transaction_id')->unsigned();
|
||||
|
||||
// connect to components
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
|
||||
// connect to transactions
|
||||
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
||||
|
||||
// combo must be unique:
|
||||
$table->unique(['component_id', 'transaction_id']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateComponentTransactionJournalTable
|
||||
*
|
||||
*/
|
||||
class CreateComponentTransactionJournalTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('component_transaction_journal');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'component_transaction_journal', function (Blueprint $table) {
|
||||
$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 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');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePreferencesTable
|
||||
*
|
||||
*/
|
||||
class CreatePreferencesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('preferences');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'preferences', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
// 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']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateSessionTable
|
||||
*
|
||||
*/
|
||||
class CreateSessionTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('sessions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)\
|
||||
*
|
||||
*
|
||||
* Class CreateLimitsTable
|
||||
*
|
||||
*/
|
||||
class CreateLimitsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('limits');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'limits', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->date('startdate');
|
||||
$table->decimal('amount', 10, 2);
|
||||
$table->boolean('repeats');
|
||||
$table->enum('repeat_freq', ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']);
|
||||
|
||||
$table->unique(['component_id', 'startdate', 'repeat_freq'], 'unique_ci_combi');
|
||||
|
||||
// connect component
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateLimitRepeatTable
|
||||
*
|
||||
*/
|
||||
class CreateLimitRepeatTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('limit_repetitions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('limit_id')->unsigned();
|
||||
$table->date('startdate');
|
||||
$table->date('enddate');
|
||||
$table->decimal('amount', 10, 2);
|
||||
|
||||
$table->unique(['limit_id', 'startdate', 'enddate']);
|
||||
|
||||
// connect limit
|
||||
$table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateComponentRecurringTransactionTable
|
||||
*
|
||||
*/
|
||||
class CreateComponentRecurringTransactionTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('component_recurring_transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
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');
|
||||
|
||||
// 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');
|
||||
|
||||
// component and recurring transaction must be unique.
|
||||
$table->unique(['component_id', 'recurring_transaction_id'], 'cid_rtid_unique');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePiggyInstance
|
||||
*
|
||||
*/
|
||||
class CreatePiggybankRepetitionsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('piggybank_repetitions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'piggybank_repetitions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('piggybank_id')->unsigned();
|
||||
$table->date('startdate')->nullable();
|
||||
$table->date('targetdate')->nullable();
|
||||
$table->decimal('currentamount', 10, 2);
|
||||
|
||||
$table->unique(['piggybank_id', 'startdate', 'targetdate']);
|
||||
|
||||
// connect instance to piggybank.
|
||||
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePiggybankEventsTable
|
||||
*
|
||||
*/
|
||||
class CreatePiggybankEventsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('piggybank_events');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'piggybank_events', function (Blueprint $table) {
|
||||
$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');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateRemindersTable
|
||||
*
|
||||
*/
|
||||
class CreateRemindersTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('reminders');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'reminders', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$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,42 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePasswordResetsTable
|
||||
*/
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('password_resets');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token')->index();
|
||||
$table->timestamp('created_at');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateAccountMetaTable
|
||||
*
|
||||
*/
|
||||
class CreateAccountMetaTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('account_meta');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
Schema::create(
|
||||
'account_meta', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('account_id')->unsigned();
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
$table->unique(['account_id', 'name']);
|
||||
|
||||
// link to account!
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreateTransactionGroupsTable
|
||||
*
|
||||
*/
|
||||
class CreateTransactionGroupsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transaction_groups');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'transaction_groups', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->enum('relation', ['balance']);
|
||||
|
||||
// connect groups to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateTransactionGroupTransactionJournalTable
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class CreateTransactionGroupTransactionJournalTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::drop('transaction_group_transaction_journal');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::create(
|
||||
'transaction_group_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$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');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,502 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Component;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName) // method names are mandated by laravel.
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*
|
||||
*
|
||||
* Down:
|
||||
* 1. Create new Components based on Budgets.
|
||||
* 2. Create new Components based on Categories
|
||||
* 3. Recreate component_id in limits
|
||||
* 4. Update all budget_limits entries (component_id).
|
||||
* 5. Add the foreign key to component_id in budget_limits
|
||||
* 6. Drop column 'budget_id' in budget_limits.
|
||||
* 7. Create table journal_components.
|
||||
* 8. create entries for budgets in journal_components.
|
||||
* 9. create entries for categories in journal_components.
|
||||
* 10. drop table budget_journals
|
||||
* 11. drop table category_journals
|
||||
* 12. drop table budgets
|
||||
* 13. drop table categories.
|
||||
* 14. rename budget_limits to limits.
|
||||
* 15. Rename piggy_bank_events to piggybank_events
|
||||
* 16. Rename field 'budget_limit_id' to 'limit_id' in 'limit_repetitions'
|
||||
* 17. Do not recreate component_recurring_transaction
|
||||
* 18. Do not recreate component_transaction
|
||||
* 19. Do not recreate field 'piggybank_id' in 'transactions'
|
||||
* 20. Drop fields from currency table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Up:
|
||||
*
|
||||
* 1. Create new budget table.
|
||||
* 2. Create new category table.
|
||||
* 3. Create journal_budget table.
|
||||
* 4. Create journal_category table.
|
||||
* 5. Move budgets to new budgets table AND move journal_components to budget_components.
|
||||
* 6. Move categories to categories table AND move journal_components to category_components.
|
||||
* 7. Rename limits to budget_limits.
|
||||
* 8. Rename piggybank_events to piggy_bank_events
|
||||
* 9. Rename field 'limit_id' to 'budget_limit_id' in 'limit_repetitions'
|
||||
* 10. Create field budget_id in budget_limits.
|
||||
* 11. Update budget_limits with budgets (instead of components).
|
||||
* 12. drop table journal_components
|
||||
* 13. Drop table component_recurring_transaction
|
||||
* 14. Drop table component_transaction
|
||||
* 15. Drop field 'piggybank_id' from 'transactions'
|
||||
* 16. Drop field 'component_id' from 'budget_limits'
|
||||
* 17. Expand currency table with new fields.
|
||||
*
|
||||
* Class ChangesForV321
|
||||
*/
|
||||
class ChangesForV321 extends Migration
|
||||
{
|
||||
public function down()
|
||||
{
|
||||
|
||||
$this->moveBudgetsBack(); // 1.
|
||||
$this->moveCategoriesBack(); // 2.
|
||||
$this->createComponentId(); // 3.
|
||||
$this->updateComponentInBudgetLimits(); // 4.
|
||||
$this->createComponentIdForeignKey(); // 5.
|
||||
$this->dropBudgetIdColumnInBudgetLimits(); // 6.
|
||||
$createComponents = new CreateComponentTransactionJournalTable; // 7.
|
||||
$createComponents->up();
|
||||
$this->moveBackEntriesForBudgetsInJoinedTable(); // 8.
|
||||
$this->moveBackEntriesForCategoriesInJoinedTable(); // 9.
|
||||
$this->dropBudgetJournalTable(); // 10.
|
||||
$this->dropCategoryJournalTable(); // 11.
|
||||
$this->dropBudgetTable(); // 12.
|
||||
$this->dropCategoryTable(); // 13.
|
||||
$this->renameBudgetLimits(); // 14.
|
||||
$this->renamePiggyBankEvents(); // 15.
|
||||
$this->renameBudgetLimitToBudgetInRepetitions(); // 16.
|
||||
// 17 and then 18 and then 19
|
||||
$this->dropFieldsFromCurrencyTable(); // 20.
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->createBudgetTable(); // 1.
|
||||
$this->createCategoryTable(); // 2.
|
||||
$this->createBudgetJournalTable(); // 3
|
||||
$this->createCategoryJournalTable(); // 4.
|
||||
$this->moveBudgets(); // 5.
|
||||
$this->moveCategories(); // 6.
|
||||
$this->correctNameForBudgetLimits(); // 7.
|
||||
$this->correctNameForPiggyBankEvents(); // 8.
|
||||
$this->renameBudgetToBudgetLimitInRepetitions(); // 9.
|
||||
$this->addBudgetIdFieldToBudgetLimits(); // 10.
|
||||
$this->moveComponentIdToBudgetId(); // 11.
|
||||
$this->dropComponentJournalTable(); // 12.
|
||||
$this->dropComponentRecurringTransactionTable(); // 13.
|
||||
$this->dropComponentTransactionTable(); // 14.
|
||||
$this->dropPiggyBankIdFromTransactions(); // 15.
|
||||
$this->dropComponentIdFromBudgetLimits(); // 16.
|
||||
$this->expandCurrencyTable(); // 17.
|
||||
|
||||
}
|
||||
|
||||
private function addBudgetIdFieldToBudgetLimits()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->integer('budget_id', false, true)->nullable()->after('updated_at');
|
||||
$table->foreign('budget_id', 'bid_foreign')->references('id')->on('budgets')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function correctNameForBudgetLimits()
|
||||
{
|
||||
Schema::rename('limits', 'budget_limits');
|
||||
}
|
||||
|
||||
private function correctNameForPiggyBankEvents()
|
||||
{
|
||||
Schema::rename('piggybank_events', 'piggy_bank_events');
|
||||
|
||||
}
|
||||
|
||||
private function createBudgetJournalTable()
|
||||
{
|
||||
Schema::create(
|
||||
'budget_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('budget_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
$table->unique(['budget_id', 'transaction_journal_id'], 'budid_tjid_unique');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function createBudgetTable()
|
||||
{
|
||||
Schema::create(
|
||||
'budgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('name', 50);
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'name']);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function createCategoryJournalTable()
|
||||
{
|
||||
Schema::create(
|
||||
'category_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
$table->unique(['category_id', 'transaction_journal_id'], 'catid_tjid_unique');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function createCategoryTable()
|
||||
{
|
||||
Schema::create(
|
||||
'categories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('name', 50);
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'name']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function createComponentId()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->integer('component_id')->unsigned();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function createComponentIdForeignKey()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->foreign('component_id', 'limits_component_id_foreign')->references('id')->on('components')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function dropBudgetIdColumnInBudgetLimits()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropForeign('bid_foreign');
|
||||
$table->dropColumn('budget_id'); // also drop foreign key!
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function dropBudgetJournalTable()
|
||||
{
|
||||
Schema::dropIfExists('budget_transaction_journal');
|
||||
}
|
||||
|
||||
private function dropBudgetTable()
|
||||
{
|
||||
Schema::dropIfExists('budgets');
|
||||
}
|
||||
|
||||
private function dropCategoryJournalTable()
|
||||
{
|
||||
Schema::dropIfExists('category_transaction_journal');
|
||||
}
|
||||
|
||||
private function dropCategoryTable()
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
|
||||
private function dropComponentIdFromBudgetLimits()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropForeign('limits_component_id_foreign');
|
||||
$table->dropColumn('component_id');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function dropComponentJournalTable()
|
||||
{
|
||||
Schema::dropIfExists('component_transaction_journal');
|
||||
}
|
||||
|
||||
private function dropComponentRecurringTransactionTable()
|
||||
{
|
||||
Schema::dropIfExists('component_recurring_transaction');
|
||||
}
|
||||
|
||||
private function dropComponentTransactionTable()
|
||||
{
|
||||
Schema::dropIfExists('component_transaction');
|
||||
}
|
||||
|
||||
private function dropFieldsFromCurrencyTable()
|
||||
{
|
||||
|
||||
Schema::table(
|
||||
'transaction_currencies', function (Blueprint $table) {
|
||||
$table->dropColumn('symbol');
|
||||
$table->dropColumn('name');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function dropPiggyBankIdFromTransactions()
|
||||
{
|
||||
|
||||
Schema::table(
|
||||
'transactions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('transactions', 'piggybank_id')) {
|
||||
$table->dropForeign('transactions_piggybank_id_foreign');
|
||||
$table->dropColumn('piggybank_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function expandCurrencyTable()
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_currencies', function (Blueprint $table) {
|
||||
$table->string('name', 48)->nullable();
|
||||
$table->string('symbol', 8)->nullable();
|
||||
}
|
||||
);
|
||||
\DB::update('UPDATE `transaction_currencies` SET `symbol` = "€", `name` = "Euro" WHERE `code` = "EUR";');
|
||||
}
|
||||
|
||||
private function moveBackEntriesForBudgetsInJoinedTable()
|
||||
{
|
||||
$set = DB::table('budget_transaction_journal')->get();
|
||||
/** @var \stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$budget = Budget::find($entry->budget_id);
|
||||
if ($budget) {
|
||||
/** @var \FireflyIII\Models\Component $component */
|
||||
$component = Component::where('class', 'Budget')->where('name', $budget->name)->where('user_id', $budget->user_id)->first();
|
||||
if ($component) {
|
||||
DB::table('component_transaction_journal')->insert(
|
||||
[
|
||||
'component_id' => $component->id,
|
||||
'transaction_journal_id' => $entry->transaction_journal_id,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function moveBackEntriesForCategoriesInJoinedTable()
|
||||
{
|
||||
$set = DB::table('category_transaction_journal')->get();
|
||||
/** @var \stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$category = Category::find($entry->category_id);
|
||||
if ($category) {
|
||||
/** @var \FireflyIII\Models\Component $component */
|
||||
$component = Component::where('class', 'Category')->where('name', $category->name)->where('user_id', $category->user_id)->first();
|
||||
if ($component) {
|
||||
DB::table('component_transaction_journal')->insert(
|
||||
[
|
||||
'component_id' => $component->id,
|
||||
'transaction_journal_id' => $entry->transaction_journal_id,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function moveBudgets()
|
||||
{
|
||||
Component::where('class', 'Budget')->get()->each(
|
||||
function (Component $c) {
|
||||
$entry = [
|
||||
'user_id' => $c->user_id,
|
||||
'name' => $c->name,
|
||||
|
||||
];
|
||||
$budget = Budget::firstOrCreate($entry);
|
||||
// create entry in budget_transaction_journal
|
||||
$connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
|
||||
/** @var \stdClass $connection */
|
||||
foreach ($connections as $connection) {
|
||||
DB::table('budget_transaction_journal')->insert(
|
||||
[
|
||||
'budget_id' => $budget->id,
|
||||
'transaction_journal_id' => $connection->transaction_journal_id,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function moveBudgetsBack()
|
||||
{
|
||||
Budget::get()->each(
|
||||
function (Budget $budget) {
|
||||
Component::firstOrCreate(
|
||||
[
|
||||
'name' => $budget->name,
|
||||
'user_id' => $budget->user_id,
|
||||
'class' => 'Budget',
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function moveCategories()
|
||||
{
|
||||
Component::where('class', 'Category')->get()->each(
|
||||
function (Component $c) {
|
||||
$entry = [
|
||||
'user_id' => $c->user_id,
|
||||
'name' => $c->name,
|
||||
|
||||
];
|
||||
$category = Category::firstOrCreate($entry);
|
||||
// create entry in category_transaction_journal
|
||||
$connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
|
||||
/** @var \stdClass $connection */
|
||||
foreach ($connections as $connection) {
|
||||
DB::table('category_transaction_journal')->insert(
|
||||
[
|
||||
'category_id' => $category->id,
|
||||
'transaction_journal_id' => $connection->transaction_journal_id,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function moveCategoriesBack()
|
||||
{
|
||||
Category::get()->each(
|
||||
function (Category $category) {
|
||||
Component::firstOrCreate(
|
||||
[
|
||||
'name' => $category->name,
|
||||
'user_id' => $category->user_id,
|
||||
'class' => 'Category',
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function moveComponentIdToBudgetId()
|
||||
{
|
||||
BudgetLimit::get()->each(
|
||||
function (BudgetLimit $bl) {
|
||||
$component = Component::find($bl->component_id);
|
||||
if ($component) {
|
||||
$budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
|
||||
if ($budget) {
|
||||
$bl->budget_id = $budget->id;
|
||||
$bl->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private function renameBudgetLimitToBudgetInRepetitions()
|
||||
{
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('limit_repetitions_budget_limit_id_foreign');
|
||||
$table->renameColumn('budget_limit_id', 'limit_id');
|
||||
$table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function renameBudgetLimits()
|
||||
{
|
||||
Schema::rename('budget_limits', 'limits');
|
||||
}
|
||||
|
||||
private function renameBudgetToBudgetLimitInRepetitions()
|
||||
{
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('limit_repetitions_limit_id_foreign');
|
||||
$table->renameColumn('limit_id', 'budget_limit_id');
|
||||
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function renamePiggyBankEvents()
|
||||
{
|
||||
Schema::rename('piggy_bank_events', 'piggybank_events');
|
||||
|
||||
}
|
||||
|
||||
private function updateComponentInBudgetLimits()
|
||||
{
|
||||
BudgetLimit::get()->each(
|
||||
function (BudgetLimit $bl) {
|
||||
$budgetId = $bl->budget_id;
|
||||
$budget = Budget::find($budgetId);
|
||||
if ($budget) {
|
||||
$component = Component::where('class', 'Budget')->where('user_id', $budget->user_id)->where('name', $budget->name)->first();
|
||||
if ($component) {
|
||||
$bl->component_id = $component->id;
|
||||
$bl->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* Class ChangesForV322
|
||||
*/
|
||||
class ChangesForV322 extends Migration
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// rename tables:
|
||||
Schema::rename('piggy_bank_repetitions', 'piggybank_repetitions');
|
||||
Schema::rename('piggy_banks', 'piggybanks');
|
||||
|
||||
// rename fields
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->dropForeign('piggy_bank_events_piggy_bank_id_foreign');
|
||||
$table->renameColumn('piggy_bank_id', 'piggybank_id');
|
||||
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'piggybank_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('piggy_bank_repetitions_piggy_bank_id_foreign');
|
||||
$table->renameColumn('piggy_bank_id', 'piggybank_id');
|
||||
$table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// remove soft delete to piggy banks
|
||||
Schema::table(
|
||||
'piggybanks', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
}
|
||||
);
|
||||
|
||||
// drop keys from bills (foreign bills_uid_for and unique uid_name_unique)
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
$table->dropForeign('bills_uid_for');
|
||||
$table->dropUnique('uid_name_unique');
|
||||
}
|
||||
);
|
||||
// drop foreign key from transaction_journals (bill_id_foreign)
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->dropForeign('bill_id_foreign');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// drop unique constraint from budget_limits:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropForeign('bid_foreign');
|
||||
$table->dropUnique('unique_bl_combi');
|
||||
$table->foreign('budget_id', 'bid_foreign')->references('id')->on('budgets')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// rename bills to recurring_transactions
|
||||
Schema::rename('bills', 'recurring_transactions');
|
||||
// recreate foreign key recurring_transactions_user_id_foreign in recurring_transactions
|
||||
// recreate unique recurring_transactions_user_id_name_unique in recurring_transactions
|
||||
Schema::table(
|
||||
'recurring_transactions', function (Blueprint $table) {
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'name']);
|
||||
}
|
||||
);
|
||||
|
||||
// rename bill_id to recurring_transaction_id
|
||||
// recreate foreign transaction_journals_recurring_transaction_id_foreign in transaction_journals
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->renameColumn('bill_id', 'recurring_transaction_id');
|
||||
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// rename tables:
|
||||
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
||||
Schema::rename('piggybanks', 'piggy_banks');
|
||||
|
||||
// recreate it the correct way:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate', 'repeat_freq'], 'unique_bl_combi');
|
||||
}
|
||||
);
|
||||
|
||||
// rename fields
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->dropForeign('piggybank_events_piggybank_id_foreign');
|
||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'piggy_bank_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('piggybank_repetitions_piggybank_id_foreign');
|
||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// add soft delete to piggy banks
|
||||
Schema::table(
|
||||
'piggy_banks', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
}
|
||||
);
|
||||
|
||||
// rename everything related to recurring transactions, aka bills:
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
|
||||
|
||||
// drop relation
|
||||
$table->dropForeign('transaction_journals_recurring_transaction_id_foreign');
|
||||
// rename column
|
||||
$table->renameColumn('recurring_transaction_id', 'bill_id');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'recurring_transactions', function (Blueprint $table) {
|
||||
$table->dropForeign('recurring_transactions_user_id_foreign');
|
||||
$table->dropUnique('recurring_transactions_user_id_name_unique');
|
||||
}
|
||||
);
|
||||
// rename table:
|
||||
Schema::rename('recurring_transactions', 'bills');
|
||||
|
||||
// recreate foreign relation:
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->foreign('bill_id', 'bill_id_foreign')->references('id')->on('bills')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
|
||||
// recreate more foreign relations.
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
// connect user id to users
|
||||
$table->foreign('user_id', 'bills_uid_for')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// for a user, the name must be unique
|
||||
$table->unique(['user_id', 'name'], 'uid_name_unique');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* Class ChangesForV325
|
||||
*/
|
||||
class ChangesForV325 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// delete an old index:
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropUnique('unique_ci_combi');
|
||||
|
||||
}
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
// don't care.
|
||||
}
|
||||
|
||||
// allow journal descriptions to be encrypted.
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->boolean('encrypted')->default(0);
|
||||
|
||||
}
|
||||
);
|
||||
try {
|
||||
DB::update('ALTER TABLE `transaction_journals` MODIFY `description` VARCHAR(1024)');
|
||||
} catch (PDOException $e) {
|
||||
// don't care.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV332
|
||||
*/
|
||||
class ChangesForV332 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->boolean('encrypted')->default(0);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'reminders', function (Blueprint $table) {
|
||||
$table->text('metadata')->nullable();
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV333
|
||||
*/
|
||||
class ChangesForV333 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->smallInteger('order', false, true)->default(0);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,244 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* Class ChangesForV336
|
||||
*/
|
||||
class ChangesForV336 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
/**
|
||||
* ACCOUNTS
|
||||
*/
|
||||
// unchange field to be encryptable.
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
// drop foreign key:
|
||||
$table->dropForeign('account_user_id');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->string('name', 255)->change();
|
||||
$table->dropColumn('virtual_balance');
|
||||
|
||||
// recreate foreign key
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// recreate unique:
|
||||
$table->unique(['user_id', 'account_type_id', 'name']);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* BILLS
|
||||
*/
|
||||
// change field to be cryptable.
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
// drop foreign key:
|
||||
$table->dropForeign('bill_user_id');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('bill_user_id');
|
||||
}
|
||||
);
|
||||
//
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
// raw query:
|
||||
|
||||
DB::insert('ALTER TABLE `bills` CHANGE `name` `name` varchar(255) NOT NULL');
|
||||
DB::insert('ALTER TABLE `bills` CHANGE `match` `match` varchar(255) NOT NULL');
|
||||
$table->foreign('user_id', 'bills_uid_for')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'name'], 'uid_name_unique');
|
||||
}
|
||||
);
|
||||
|
||||
// remove a long forgotten index:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropUnique('unique_limit');
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
/**
|
||||
* ACCOUNTS
|
||||
*/
|
||||
// change field to be cryptable.
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
// drop foreign key:
|
||||
$table->dropForeign('accounts_user_id_foreign');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('accounts_user_id_account_type_id_name_unique');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->text('name')->change();
|
||||
$table->decimal('virtual_balance', 10, 2)->default(0);
|
||||
$table->foreign('user_id', 'account_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* BUDGETS
|
||||
*/
|
||||
// add active/inactive and encrypt.
|
||||
Schema::table(
|
||||
'budgets', function (Blueprint $table) {
|
||||
$table->smallInteger('active', false, true)->default(1);
|
||||
$table->smallInteger('encrypted', false, true)->default(0);
|
||||
|
||||
// drop foreign key:
|
||||
$table->dropForeign('budgets_user_id_foreign');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('budgets_user_id_name_unique');
|
||||
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budgets', function (Blueprint $table) {
|
||||
$table->text('name')->change();
|
||||
$table->foreign('user_id', 'budget_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// reinstate a long forgotten index:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate'], 'unique_limit');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* BILLS
|
||||
*/
|
||||
// change field to be cryptable.
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
// drop foreign key:
|
||||
$table->dropForeign('bills_uid_for');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('uid_name_unique');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
// raw query:
|
||||
try {
|
||||
DB::insert('ALTER TABLE `bills` CHANGE `name` `name` TEXT NOT NULL');
|
||||
} catch (PDOException $e) {
|
||||
// don't care.
|
||||
}
|
||||
try {
|
||||
DB::insert('ALTER TABLE `bills` CHANGE `match` `match` TEXT NOT NULL');
|
||||
} catch (PDOException $e) {
|
||||
// don't care.
|
||||
}
|
||||
$table->smallInteger('name_encrypted', false, true)->default(0);
|
||||
$table->smallInteger('match_encrypted', false, true)->default(0);
|
||||
$table->foreign('user_id', 'bill_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* CATEGORIES
|
||||
*/
|
||||
Schema::table(
|
||||
'categories', function (Blueprint $table) {
|
||||
$table->smallInteger('encrypted', false, true)->default(0);
|
||||
|
||||
// drop foreign key:
|
||||
$table->dropForeign('categories_user_id_foreign');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('categories_user_id_name_unique');
|
||||
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'categories', function (Blueprint $table) {
|
||||
$table->text('name')->change();
|
||||
$table->foreign('user_id', 'category_user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* PIGGY BANKS
|
||||
*/
|
||||
Schema::table(
|
||||
'piggy_banks', function (Blueprint $table) {
|
||||
$table->smallInteger('encrypted', false, true)->default(0);
|
||||
|
||||
// drop foreign:
|
||||
$table->dropForeign('piggybanks_account_id_foreign');
|
||||
|
||||
// drop unique:
|
||||
$table->dropUnique('piggybanks_account_id_name_unique');
|
||||
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'piggy_banks', function (Blueprint $table) {
|
||||
try {
|
||||
DB::insert('ALTER TABLE `piggy_banks` CHANGE `name` `name` TEXT NOT NULL');
|
||||
} catch (PDOException $e) {
|
||||
// don't care.
|
||||
}
|
||||
$table->dropColumn(['repeats', 'rep_length', 'rep_every', 'rep_times']);
|
||||
|
||||
// create index again:
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* REMINDERS
|
||||
*/
|
||||
Schema::table(
|
||||
'reminders', function (Blueprint $table) {
|
||||
$table->smallInteger('encrypted', false, true)->default(0);
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* Class ChangesForV3310
|
||||
*/
|
||||
class ChangesForV3310 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('tag_transaction_journal');
|
||||
Schema::drop('tags');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
Schema::table(
|
||||
'transaction_groups', function (Blueprint $table) {
|
||||
|
||||
// drop column "relation"
|
||||
$table->dropColumn('relation');
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* New table!
|
||||
*/
|
||||
Schema::create(
|
||||
'tags', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('tag', 1024);
|
||||
$table->string('tagMode', 1024);
|
||||
$table->date('date')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->decimal('latitude', 18, 12)->nullable();
|
||||
$table->decimal('longitude', 18, 12)->nullable();
|
||||
$table->smallInteger('zoomLevel', false, true)->nullable();
|
||||
|
||||
// connect tags to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Schema::create(
|
||||
'tag_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('tag_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
|
||||
// link to foreign tables.
|
||||
$table->foreign('tag_id', 'tag_grp_id')->references('id')->on('tags')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id', 'tag_trj_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
// add unique.
|
||||
$table->unique(['tag_id', 'transaction_journal_id'], 'tag_t_joined');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV3310a
|
||||
*/
|
||||
class ChangesForV3310a extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_groups', function (Blueprint $table) {
|
||||
|
||||
// new column, relation.
|
||||
$table->string('relation', 50)->nullable();
|
||||
}
|
||||
);
|
||||
// make new column "relation"
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV3310b
|
||||
*/
|
||||
class ChangesForV3310b extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// set all current entries to be "balance"
|
||||
DB::table('transaction_groups')->update(['relation' => 'balance']);
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV3409
|
||||
*/
|
||||
class ChangesForV3409 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(
|
||||
'preferences', function (Blueprint $table) {
|
||||
$table->dropColumn('name_encrypted');
|
||||
$table->dropColumn('data_encrypted');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
// encrypt preference name (add field)
|
||||
// encrypt preference data (add field)
|
||||
Schema::table(
|
||||
'preferences', function (Blueprint $table) {
|
||||
$table->text('name_encrypted')->nullable()->after('name');
|
||||
$table->text('data_encrypted')->nullable()->after('data');
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class EntrustSetupTables
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
class EntrustSetupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('permission_role');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('role_user');
|
||||
Schema::drop('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Create table for storing roles
|
||||
Schema::create(
|
||||
'roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
|
||||
// Create table for associating roles to users (Many-to-Many)
|
||||
Schema::create(
|
||||
'role_user', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'role_id']);
|
||||
}
|
||||
);
|
||||
|
||||
// Create table for storing permissions
|
||||
Schema::create(
|
||||
'permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
|
||||
// Create table for associating permissions to roles (Many-to-Many)
|
||||
Schema::create(
|
||||
'permission_role', function (Blueprint $table) {
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id']);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV345
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
class ChangesForV345 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->dropColumn('tag_count');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->smallInteger('tag_count', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV3462
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class ChangesForV3462 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->dropColumn('iban');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// add IBAN to accounts:
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->string('iban')->nullable();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV349
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class ChangesForV349 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// add "blocked" to users:
|
||||
Schema::table(
|
||||
'users', function (Blueprint $table) {
|
||||
$table->boolean('blocked')->default(0);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV3410
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
class ChangesForV3410 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('attachments');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'attachments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('attachable_id')->unsigned();
|
||||
$table->string('attachable_type');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('md5', 32);
|
||||
$table->text('filename');
|
||||
$table->text('title')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('mime');
|
||||
$table->integer('size')->unsigned();
|
||||
$table->tinyInteger('uploaded', false, true)->default(0);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// add "blocked_code" to users:
|
||||
Schema::table(
|
||||
'users', function (Blueprint $table) {
|
||||
$table->string('blocked_code', 25)->nullable();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* 2016_01_11_193428_changes_for_v370.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV370
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
class ChangesForV370 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('rule_actions');
|
||||
Schema::drop('rule_triggers');
|
||||
Schema::drop('rules');
|
||||
Schema::drop('rule_groups');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// extend transaction journals:
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->date('interest_date')->nullable()->after('date');
|
||||
$table->date('book_date')->nullable()->after('interest_date');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// new table "rule_groups"
|
||||
Schema::create(
|
||||
'rule_groups', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->string('title', 255);
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
|
||||
// connect rule groups to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Schema::create(
|
||||
'rules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('rule_group_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
$table->string('title', 255);
|
||||
$table->text('description')->nullable();
|
||||
|
||||
|
||||
// connect rules to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// connect rules to rule groups
|
||||
$table->foreign('rule_group_id')->references('id')->on('rule_groups')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// new table "rule_triggers"
|
||||
Schema::create(
|
||||
'rule_triggers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('rule_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
$table->string('trigger_type', 50);
|
||||
$table->string('trigger_value', 255)->nullable();
|
||||
|
||||
// connect rule triggers to rules
|
||||
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
// new table "rule_actions"
|
||||
Schema::create(
|
||||
'rule_actions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('rule_id')->unsigned();
|
||||
$table->unsignedSmallInteger('order');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('stop_processing')->default(0);
|
||||
|
||||
$table->string('action_type', 50);
|
||||
$table->string('action_value', 255)->nullable();
|
||||
|
||||
// connect rule actions to rules
|
||||
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV380
|
||||
*/
|
||||
class ChangesForV380 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('export_jobs');
|
||||
Schema::drop('journal_meta');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
// extend transaction journals:
|
||||
Schema::table(
|
||||
'transaction_journals', function (Blueprint $table) {
|
||||
$table->date('process_date')->nullable()->after('book_date');
|
||||
}
|
||||
);
|
||||
|
||||
// new table "export_jobs"
|
||||
Schema::create(
|
||||
'export_jobs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('key', 12)->unique();
|
||||
$table->string('status', 45);
|
||||
|
||||
// connect rule groups to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// new table for transaction journal meta, "journal_meta"
|
||||
Schema::create(
|
||||
'journal_meta', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
$table->unique(['transaction_journal_id', 'name']);
|
||||
|
||||
// link to transaction journal
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateJobsTable
|
||||
*/
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->tinyInteger('reserved')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
$table->index(['queue', 'reserved', 'reserved_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('jobs');
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
|
||||
/**
|
||||
* Class ChangesForV383
|
||||
*/
|
||||
class ChangesForV383 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// extend journal meta
|
||||
Schema::table(
|
||||
'journal_meta', function (Blueprint $table) {
|
||||
$table->string('hash', 64)->nullable();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV390
|
||||
*/
|
||||
class ChangesForV390 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// restore removed unique index. Recreate it the correct way:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate', 'repeat_freq'], 'unique_bl_combi');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$backup = $this->backupRepeatFreqsFromString();
|
||||
|
||||
// drop string and create enum field
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropColumn('repeat_freq');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->enum('repeat_freq', ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']);
|
||||
}
|
||||
);
|
||||
|
||||
// restore backup. Change unknowns to "monthly".
|
||||
$this->restoreRepeatFreqsToEnum($backup);
|
||||
|
||||
// drop budget <> transaction table:
|
||||
Schema::dropIfExists('budget_transaction');
|
||||
|
||||
// drop category <> transaction table:
|
||||
Schema::dropIfExists('category_transaction');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// // remove an index.
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropForeign('bid_foreign');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropUnique('unique_limit');
|
||||
$table->dropUnique('unique_bl_combi');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// recreate foreign key:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->foreign('budget_id', 'bid_foreign')->references('id')->on('budgets')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// backup values
|
||||
$backup = $this->backupRepeatFreqsFromEnum();
|
||||
|
||||
// drop enum and create varchar field
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropColumn('repeat_freq');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->string('repeat_freq', 20)->default('monthly');
|
||||
}
|
||||
);
|
||||
|
||||
// put data back:
|
||||
$this->restoreRepeatFreqsToVarchar($backup);
|
||||
|
||||
|
||||
// create it again, correctly.
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate', 'repeat_freq'], 'unique_limit');
|
||||
}
|
||||
);
|
||||
|
||||
// create NEW table for transactions <> budgets
|
||||
Schema::create(
|
||||
'budget_transaction', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('budget_id')->unsigned();
|
||||
$table->integer('transaction_id')->unsigned();
|
||||
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
||||
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
||||
$table->unique(['budget_id', 'transaction_id'], 'budid_tid_unique');
|
||||
}
|
||||
);
|
||||
|
||||
// create NEW table for transactions <> categories
|
||||
Schema::create(
|
||||
'category_transaction', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->integer('transaction_id')->unsigned();
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
|
||||
$table->unique(['category_id', 'transaction_id'], 'catid_tid_unique');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function backupRepeatFreqsFromEnum(): array
|
||||
{
|
||||
$backup = [];
|
||||
$set = BudgetLimit::get();
|
||||
/** @var BudgetLimit $entry */
|
||||
foreach ($set as $entry) {
|
||||
$backup[$entry->id] = $entry->repeat_freq;
|
||||
}
|
||||
|
||||
return $backup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same routine.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function backupRepeatFreqsFromString()
|
||||
{
|
||||
return $this->backupRepeatFreqsFromEnum();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $backup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function restoreRepeatFreqsToEnum(array $backup): bool
|
||||
{
|
||||
foreach ($backup as $id => $repeatFreq) {
|
||||
$budgetLimit = BudgetLimit::find($id);
|
||||
if (!in_array($repeatFreq, ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'])) {
|
||||
$repeatFreq = 'monthly';
|
||||
}
|
||||
$budgetLimit->repeat_freq = $repeatFreq;
|
||||
$budgetLimit->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $backup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function restoreRepeatFreqsToVarchar(array $backup): bool
|
||||
{
|
||||
foreach ($backup as $id => $repeatFreq) {
|
||||
$budgetLimit = BudgetLimit::find($id);
|
||||
$budgetLimit->repeat_freq = $repeatFreq;
|
||||
$budgetLimit->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
183
database/migrations/2016_06_16_192032_create_support_tables.php
Normal file
183
database/migrations/2016_06_16_192032_create_support_tables.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateSupportTables
|
||||
*/
|
||||
class CreateSupportTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
Schema::drop('account_types');
|
||||
Schema::drop('transaction_currencies');
|
||||
Schema::drop('transaction_types');
|
||||
Schema::drop('jobs');
|
||||
Schema::drop('password_resets');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('roles');
|
||||
Schema::drop('permission_role');
|
||||
Schema::drop('sessions');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
* account_types
|
||||
*/
|
||||
if (!Schema::hasTable('account_types')) {
|
||||
Schema::create(
|
||||
'account_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('type', 50);
|
||||
|
||||
// type must be unique.
|
||||
$table->unique(['type']);
|
||||
}
|
||||
);
|
||||
}
|
||||
/*
|
||||
* transaction_currencies
|
||||
*/
|
||||
if (!Schema::hasTable('transaction_currencies')) {
|
||||
Schema::create(
|
||||
'transaction_currencies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('code', 3);
|
||||
$table->string('name', 255);
|
||||
$table->string('symbol', 12);
|
||||
|
||||
// code must be unique.
|
||||
$table->unique(['code']);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* transaction_types
|
||||
*/
|
||||
if (!Schema::hasTable('transaction_types')) {
|
||||
Schema::create(
|
||||
'transaction_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('type', 50);
|
||||
|
||||
// type must be unique.
|
||||
$table->unique(['type']);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* jobs
|
||||
*/
|
||||
if (!Schema::hasTable('jobs')) {
|
||||
Schema::create(
|
||||
'jobs', function (Blueprint $table) {
|
||||
|
||||
// straight from Laravel
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->tinyInteger('reserved')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
$table->index(['queue', 'reserved', 'reserved_at']);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* password_resets
|
||||
*/
|
||||
if (!Schema::hasTable('password_resets')) {
|
||||
Schema::create(
|
||||
'password_resets', function (Blueprint $table) {
|
||||
// straight from laravel
|
||||
$table->string('email')->index();
|
||||
$table->string('token')->index();
|
||||
$table->timestamp('created_at');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* permissions
|
||||
*/
|
||||
if (!Schema::hasTable('permissions')) {
|
||||
Schema::create(
|
||||
'permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* roles
|
||||
*/
|
||||
if (!Schema::hasTable('roles')) {
|
||||
Schema::create(
|
||||
'roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* permission_role
|
||||
*/
|
||||
if (!Schema::hasTable('permission_role')) {
|
||||
Schema::create(
|
||||
'permission_role', function (Blueprint $table) {
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* sessions
|
||||
*/
|
||||
if (!Schema::hasTable('sessions')) {
|
||||
Schema::create(
|
||||
'sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user