mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +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
|
||||
{
|
||||
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.');
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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".
|
||||
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"
|
||||
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"
|
||||
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
|
||||
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".
|
||||
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"
|
||||
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"
|
||||
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".
|
||||
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,10 +38,8 @@ class ChangesForV440 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('currency_exchange_rates')) {
|
||||
Schema::dropIfExists('currency_exchange_rates');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -53,6 +52,10 @@ class ChangesForV440 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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,6 +91,7 @@ class ChangesForV440 extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -97,5 +101,9 @@ class ChangesForV440 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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,13 +39,19 @@ class ChangesForV450 extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
// split up for sqlite compatibility
|
||||
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.');
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -53,13 +61,22 @@ class ChangesForV450 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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,14 +87,20 @@ class ChangesForV450 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// add "foreign_amount" to transactions
|
||||
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):
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -85,5 +108,9 @@ class ChangesForV450 extends Migration
|
||||
$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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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.');
|
||||
}
|
||||
|
||||
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,6 +42,7 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
@@ -50,13 +53,23 @@ class ChangesForV473 extends Migration
|
||||
$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.');
|
||||
}
|
||||
|
||||
|
||||
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,6 +80,7 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
@@ -74,11 +88,20 @@ class ChangesForV473 extends Migration
|
||||
$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,7 +85,7 @@ 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 {
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_transactions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -109,12 +109,12 @@ try {
|
||||
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
} 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 {
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_repetitions',
|
||||
static function (Blueprint $table) {
|
||||
@@ -130,12 +130,12 @@ try {
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
} 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 {
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_meta',
|
||||
static function (Blueprint $table) {
|
||||
@@ -150,11 +150,11 @@ try {
|
||||
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
} 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 {
|
||||
}
|
||||
try {
|
||||
Schema::create(
|
||||
'rt_meta',
|
||||
static function (Blueprint $table) {
|
||||
@@ -169,9 +169,9 @@ try {
|
||||
$table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
} 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,6 +41,7 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
@@ -50,6 +53,10 @@ class ChangesForV477 extends Migration
|
||||
$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,6 +67,7 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
@@ -67,5 +75,9 @@ class ChangesForV477 extends Migration
|
||||
$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
|
||||
{
|
||||
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
|
||||
{
|
||||
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.
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
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
|
||||
{
|
||||
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.
|
||||
*/
|
||||
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
|
||||
{
|
||||
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.');
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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) {
|
||||
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,6 +110,7 @@ class ChangesForV480 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
@@ -82,20 +121,41 @@ class ChangesForV480 extends Migration
|
||||
->nullable()->default(null)->after('transaction_type_id');
|
||||
|
||||
// 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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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.');
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
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,18 +88,29 @@ class ChangesForV540 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
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) {
|
||||
@@ -89,12 +118,21 @@ class ChangesForV540 extends Migration
|
||||
$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:
|
||||
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,6 +65,7 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
|
||||
// expand budget / transaction journal table.
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
@@ -71,11 +73,16 @@ class ChangesForV550 extends Migration
|
||||
$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
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
@@ -83,6 +90,10 @@ class ChangesForV550 extends Migration
|
||||
$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,6 +149,7 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
|
||||
// update budget / transaction journal table.
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_transaction_journal',
|
||||
function (Blueprint $table) {
|
||||
@@ -147,9 +159,14 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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.
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
static function (Blueprint $table) {
|
||||
@@ -161,6 +178,10 @@ class ChangesForV550 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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,6 +40,7 @@ class ChangesForV550b2 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
@@ -47,6 +50,10 @@ class ChangesForV550b2 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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,6 +64,7 @@ class ChangesForV550b2 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// expand recurrence transaction table
|
||||
try {
|
||||
Schema::table(
|
||||
'recurrences_transactions',
|
||||
function (Blueprint $table) {
|
||||
@@ -66,5 +74,9 @@ class ChangesForV550b2 extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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
|
||||
{
|
||||
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
|
||||
{
|
||||
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,6 +49,7 @@ class ExtendCurrencyInfo extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_currencies',
|
||||
function (Blueprint $table) {
|
||||
@@ -55,5 +57,9 @@ class ExtendCurrencyInfo extends Migration
|
||||
$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,6 +60,7 @@ 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) {
|
||||
@@ -68,8 +70,13 @@ class UserGroups extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
@@ -79,6 +86,10 @@ class UserGroups extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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('group_memberships');
|
||||
Schema::dropIfExists('user_roles');
|
||||
@@ -150,6 +161,7 @@ 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.');
|
||||
}
|
||||
try {
|
||||
Schema::table(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
@@ -159,21 +171,30 @@ class UserGroups extends Migration
|
||||
}
|
||||
}
|
||||
);
|
||||
} 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) {
|
||||
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'
|
||||
);
|
||||
$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
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
try {
|
||||
$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
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'currency_exchange_rates',
|
||||
function (Blueprint $table) {
|
||||
try {
|
||||
$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 {
|
||||
$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