mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-13 16:00:13 +00:00
Catch DB errors
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesFor3101.
|
||||
@@ -36,14 +35,6 @@ class ChangesFor3101 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
if (Schema::hasColumn('import_jobs', 'extended_status')) {
|
||||
$table->dropColumn('extended_status');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,13 +44,5 @@ class ChangesFor3101 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('import_jobs', 'extended_status')) {
|
||||
$table->text('extended_status')->nullable();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -45,18 +46,28 @@ class FixNullables extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not update table: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -36,12 +38,17 @@ class ExpandTransactionsTable extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('identifier');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('identifier');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not drop column "extended_status": %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,11 +58,16 @@ class ExpandTransactionsTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->smallInteger('identifier', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->smallInteger('identifier', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -36,12 +37,17 @@ class ChangesForV420 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'journal_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'journal_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,11 +57,16 @@ class ChangesForV420 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'journal_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'journal_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -37,41 +39,66 @@ class ChangesForV431 extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
// reinstate "repeats" and "repeat_freq".
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('repeat_freq', 30)->nullable();
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('repeats')->default(0);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('repeat_freq', 30)->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('repeats')->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// change field "start_date" to "startdate"
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// remove date field "end_date"
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('end_date');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('end_date');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
// remove decimal places
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('decimal_places');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('decimal_places');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,41 +110,66 @@ class ChangesForV431 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// add decimal places to "transaction currencies".
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->smallInteger('decimal_places', false, true)->default(2);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->smallInteger('decimal_places', false, true)->default(2);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// change field "startdate" to "start_date"
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// add date field "end_date" after "start_date"
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->date('end_date')->nullable()->after('start_date');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->date('end_date')->nullable()->after('start_date');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// drop "repeats" and "repeat_freq".
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('repeats');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('repeat_freq');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('repeats');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('repeat_freq');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -37,22 +38,24 @@ class ChangesForV440 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('currency_exchange_rates')) {
|
||||
Schema::dropIfExists('currency_exchange_rates');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
if (Schema::hasColumn('transactions', 'transaction_currency_id')) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('transactions_transaction_currency_id_foreign');
|
||||
Schema::dropIfExists('currency_exchange_rates');
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
if (Schema::hasColumn('transactions', 'transaction_currency_id')) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('transactions_transaction_currency_id_foreign');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,14 +91,19 @@ class ChangesForV440 extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {
|
||||
$table->integer('transaction_currency_id', false, true)->after('description')->nullable();
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {
|
||||
$table->integer('transaction_currency_id', false, true)->after('description')->nullable();
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -37,29 +39,44 @@ class ChangesForV450 extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
// split up for sqlite compatibility
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('foreign_amount');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('transactions_foreign_currency_id_foreign');
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('foreign_amount');
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('foreign_currency_id');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('transactions_foreign_currency_id_foreign');
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('foreign_currency_id');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,20 +87,30 @@ class ChangesForV450 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// add "foreign_amount" to transactions
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// add foreign transaction currency id to transactions (is nullable):
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();
|
||||
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();
|
||||
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -37,12 +39,17 @@ class ChangesForV470a extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,11 +59,16 @@ class ChangesForV470a extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->after('deleted_at')->default(0);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->after('deleted_at')->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -39,18 +41,29 @@ class ChangesForV472 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'attachments',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('notes')->nullable();
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'attachments',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('notes')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,18 +74,28 @@ class ChangesForV472 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'attachments',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'attachments',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('notes');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->mediumInteger('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->mediumInteger('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -40,23 +42,34 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('bills_transaction_currency_id_foreign');
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('bills_transaction_currency_id_foreign');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('strict');
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('strict');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,18 +80,28 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('strict')->default(true);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'rules',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('strict')->default(true);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV474.
|
||||
@@ -34,57 +33,11 @@ class ChangesForV474 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// split up for sqlite compatibility.
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('import_jobs_tag_id_foreign');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('provider');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('stage');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('transactions');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('errors');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('tag_id');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,17 +48,5 @@ class ChangesForV474 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'import_jobs',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('provider', 50)->after('file_type')->default('');
|
||||
$table->string('stage', 50)->after('status')->default('');
|
||||
$table->longText('transactions')->after('extended_status')->nullable();
|
||||
$table->longText('errors')->after('transactions')->nullable();
|
||||
|
||||
$table->integer('tag_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -85,93 +85,93 @@ class ChangesForV475 extends Migration
|
||||
Log::error(sprintf('Could not create table "recurrences": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
$table->integer('transaction_currency_id', false, true);
|
||||
$table->integer('foreign_currency_id', false, true)->nullable();
|
||||
$table->integer('source_id', false, true);
|
||||
$table->integer('destination_id', false, true);
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
$table->integer('transaction_currency_id', false, true);
|
||||
$table->integer('foreign_currency_id', false, true)->nullable();
|
||||
$table->integer('source_id', false, true);
|
||||
$table->integer('destination_id', false, true);
|
||||
|
||||
$table->decimal('amount', 32, 12);
|
||||
$table->decimal('foreign_amount', 32, 12)->nullable();
|
||||
$table->string('description', 1024);
|
||||
$table->decimal('amount', 32, 12);
|
||||
$table->decimal('foreign_amount', 32, 12)->nullable();
|
||||
$table->string('description', 1024);
|
||||
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
$table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
$table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_repetitions',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
$table->string('repetition_type', 50);
|
||||
$table->string('repetition_moment', 50);
|
||||
$table->smallInteger('repetition_skip', false, true);
|
||||
$table->smallInteger('weekend', false, true);
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_repetitions',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
$table->string('repetition_type', 50);
|
||||
$table->string('repetition_moment', 50);
|
||||
$table->smallInteger('repetition_skip', false, true);
|
||||
$table->smallInteger('weekend', false, true);
|
||||
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
|
||||
$table->string('name', 50);
|
||||
$table->text('value');
|
||||
$table->string('name', 50);
|
||||
$table->text('value');
|
||||
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
try {
|
||||
Schema::create(
|
||||
'rt_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('rt_id', false, true);
|
||||
try {
|
||||
Schema::create(
|
||||
'rt_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('rt_id', false, true);
|
||||
|
||||
$table->string('name', 50);
|
||||
$table->text('value');
|
||||
$table->string('name', 50);
|
||||
$table->text('value');
|
||||
|
||||
$table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade');
|
||||
$table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "rt_meta": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "rt_meta": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -39,17 +41,22 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('budget_limits_transaction_currency_id_foreign');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('budget_limits_transaction_currency_id_foreign');
|
||||
}
|
||||
|
||||
$table->dropColumn(['transaction_currency_id']);
|
||||
}
|
||||
);
|
||||
$table->dropColumn(['transaction_currency_id']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,12 +67,17 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -39,12 +41,17 @@ class ChangesForV479 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn(['enabled']);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn(['enabled']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,11 +62,16 @@ class ChangesForV479 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(0)->after('deleted_at');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(0)->after('deleted_at');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -59,18 +60,28 @@ class ChangesForV4711 extends Migration
|
||||
* datetime (without a time zone) for all database engines because MySQL refuses to play
|
||||
* nice.
|
||||
*/
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->dateTime('date')->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->dateTime('date')->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'preferences',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('data')->nullable()->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'preferences',
|
||||
static function (Blueprint $table) {
|
||||
$table->text('data')->nullable()->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -58,11 +59,16 @@ class ChangesForV4712 extends Migration
|
||||
* datetime (without a time zone) for all database engines because MySQL refuses to play
|
||||
* nice.
|
||||
*/
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->dateTime('date')->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->dateTime('date')->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -39,12 +41,17 @@ class FixLdapConfiguration extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn(['objectguid']);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn(['objectguid']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,11 +66,16 @@ class FixLdapConfiguration extends Migration
|
||||
* ADLdap2 appears to require the ability to store an objectguid for LDAP users
|
||||
* now. To support this, we add the column.
|
||||
*/
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->uuid('objectguid')->nullable()->after('id');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->uuid('objectguid')->nullable()->after('id');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -38,30 +40,66 @@ class ChangesForV480 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
// drop transaction_group_id + foreign key.
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
$table->dropForeign('transaction_journals_transaction_group_id_foreign');
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
// drop transaction_group_id + foreign key.
|
||||
// cannot drop foreign keys in SQLite:
|
||||
if ('sqlite' !== config('database.default')) {
|
||||
try {
|
||||
$table->dropForeign('transaction_journals_transaction_group_id_foreign');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not drop foreign ID: %s', $e->getMessage()));
|
||||
Log::error('If the foreign ID does not exist (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
try {
|
||||
$table->dropColumn('transaction_group_id');
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
$table->dropColumn('transaction_group_id');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('stop_processing');
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('mfa_secret');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
try {
|
||||
$table->dropColumn('stop_processing');
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
try {
|
||||
$table->dropColumn('mfa_secret');
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,30 +110,52 @@ class ChangesForV480 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->change();
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->change();
|
||||
|
||||
// add column "group_id" after "transaction_type_id"
|
||||
$table->integer('transaction_group_id', false, true)
|
||||
->nullable()->default(null)->after('transaction_type_id');
|
||||
// add column "group_id" after "transaction_type_id"
|
||||
$table->integer('transaction_group_id', false, true)
|
||||
->nullable()->default(null)->after('transaction_type_id');
|
||||
|
||||
// add foreign key for "transaction_group_id"
|
||||
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('stop_processing')->default(false);
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('mfa_secret', 50)->nullable();
|
||||
}
|
||||
);
|
||||
// add foreign key for "transaction_group_id"
|
||||
try {
|
||||
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create foreign index: %s', $e->getMessage()));
|
||||
Log::error(
|
||||
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'rule_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->boolean('stop_processing')->default(false);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('mfa_secret', 50)->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -40,12 +42,17 @@ class ChangesForV530a extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,11 +62,16 @@ class ChangesForV530a extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -40,27 +42,43 @@ class ChangesForV540 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('provider');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('provider');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'accounts',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'accounts',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('end_date');
|
||||
$table->dropColumn('extension_date');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('end_date');
|
||||
|
||||
$table->dropColumn('extension_date');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,31 +88,51 @@ class ChangesForV540 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'accounts',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('provider')->nullable();
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->date('end_date')->nullable()->after('date');
|
||||
$table->date('extension_date')->nullable()->after('end_date');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'accounts',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('order', false, true)->default(0);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('provider')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->date('end_date')->nullable()->after('date');
|
||||
$table->date('extension_date')->nullable()->after('end_date');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
// make column nullable:
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
function (Blueprint $table) {
|
||||
$table->string('secret', 100)->nullable()->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'oauth_clients',
|
||||
function (Blueprint $table) {
|
||||
$table->string('secret', 100)->nullable()->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -64,25 +65,35 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
|
||||
// expand budget / transaction journal table.
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('budget_id_foreign');
|
||||
$table->dropColumn('budget_limit_id');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('budget_id_foreign');
|
||||
$table->dropColumn('budget_limit_id');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// drop failed jobs table.
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
|
||||
// drop fields from budget limits
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('period');
|
||||
$table->dropColumn('generated');
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('period');
|
||||
$table->dropColumn('generated');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
Schema::dropIfExists('webhook_attempts');
|
||||
Schema::dropIfExists('webhook_messages');
|
||||
Schema::dropIfExists('webhooks');
|
||||
@@ -138,29 +149,39 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
|
||||
// update budget / transaction journal table.
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
|
||||
$table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');
|
||||
$table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
|
||||
$table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');
|
||||
$table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// append budget limits table.
|
||||
// i swear I dropped & recreated this field 15 times already.
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('budget_limits', 'period')) {
|
||||
$table->string('period', 12)->nullable();
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('budget_limits', 'period')) {
|
||||
$table->string('period', 12)->nullable();
|
||||
}
|
||||
if (!Schema::hasColumn('budget_limits', 'generated')) {
|
||||
$table->boolean('generated')->default(false);
|
||||
}
|
||||
}
|
||||
if (!Schema::hasColumn('budget_limits', 'generated')) {
|
||||
$table->boolean('generated')->default(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// new webhooks table
|
||||
if (!Schema::hasTable('webhooks')) {
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -38,15 +40,20 @@ class ChangesForV550b2 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('type_foreign');
|
||||
if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
|
||||
$table->dropColumn('transaction_type_id');
|
||||
try {
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('type_foreign');
|
||||
if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
|
||||
$table->dropColumn('transaction_type_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,14 +64,19 @@ class ChangesForV550b2 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// expand recurrence transaction table
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
|
||||
$table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id');
|
||||
$table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null');
|
||||
try {
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
|
||||
$table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id');
|
||||
$table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -33,12 +35,17 @@ class AddLdapColumnsToUsersTable extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->dropColumn(['domain']);
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->dropColumn(['domain']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,11 +53,16 @@ class AddLdapColumnsToUsersTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->string('domain')->nullable();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->string('domain')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -48,12 +49,17 @@ class ExtendCurrencyInfo extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
function (Blueprint $table) {
|
||||
$table->string('code', 51)->change();
|
||||
$table->string('symbol', 51)->change();
|
||||
}
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
function (Blueprint $table) {
|
||||
$table->string('code', 51)->change();
|
||||
$table->string('symbol', 51)->change();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -59,27 +60,37 @@ class UserGroups extends Migration
|
||||
// remove columns from tables
|
||||
/** @var string $tableName */
|
||||
foreach ($this->tables as $tableName) {
|
||||
try {
|
||||
Schema::table(
|
||||
$tableName,
|
||||
function (Blueprint $table) use ($tableName) {
|
||||
$table->dropForeign(sprintf('%s_to_ugi', $tableName));
|
||||
if (Schema::hasColumn($tableName, 'user_group_id')) {
|
||||
$table->dropColumn('user_group_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
$tableName,
|
||||
function (Blueprint $table) use ($tableName) {
|
||||
$table->dropForeign(sprintf('%s_to_ugi', $tableName));
|
||||
if (Schema::hasColumn($tableName, 'user_group_id')) {
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('type_user_group_id');
|
||||
if (Schema::hasColumn('users', 'user_group_id')) {
|
||||
$table->dropColumn('user_group_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('type_user_group_id');
|
||||
if (Schema::hasColumn('users', 'user_group_id')) {
|
||||
$table->dropColumn('user_group_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Schema::dropIfExists('group_memberships');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('user_groups');
|
||||
@@ -150,30 +161,40 @@ class UserGroups extends Migration
|
||||
Log::error(sprintf('Could not create table "group_memberships": %s', $e->getMessage()));
|
||||
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
|
||||
}
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('users', 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable();
|
||||
$table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('users', 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable();
|
||||
$table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
|
||||
// ADD columns from tables
|
||||
/** @var string $tableName */
|
||||
foreach ($this->tables as $tableName) {
|
||||
Schema::table(
|
||||
$tableName,
|
||||
function (Blueprint $table) use ($tableName) {
|
||||
if (!Schema::hasColumn($tableName, 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete('set null')->onUpdate(
|
||||
'cascade'
|
||||
);
|
||||
try {
|
||||
Schema::table(
|
||||
$tableName,
|
||||
function (Blueprint $table) use ($tableName) {
|
||||
if (!Schema::hasColumn($tableName, 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete(
|
||||
'set null'
|
||||
)->onUpdate('cascade');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -39,25 +40,20 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
try {
|
||||
try {
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));
|
||||
Log::error('If the column exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
|
||||
}
|
||||
try {
|
||||
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));
|
||||
Log::error('If the foreign key exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,24 +63,19 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
try {
|
||||
try {
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
$table->dropForeign('cer_to_ugi');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));
|
||||
Log::error('If the foreign key does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
|
||||
}
|
||||
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
try {
|
||||
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
$table->dropColumn('user_group_id');
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
|
||||
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user