mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge pull request #7353 from firefly-iii/migration-checks
Catch all possible migration errors
This commit is contained in:
commit
b91e019416
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@ -9,7 +11,7 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ForceDecimalSize extends Command
|
||||
{
|
||||
use VerifiesAccessToken;
|
||||
use VerifiesAccessToken;
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
@ -52,6 +52,7 @@ use Illuminate\Support\Carbon;
|
||||
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
|
||||
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class UserGroup extends Model
|
||||
|
15
composer.lock
generated
15
composer.lock
generated
@ -4075,16 +4075,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7",
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Nyholm/psr7.git",
|
||||
"reference": "f734364e38a876a23be4d906a2a089e1315be18a"
|
||||
"reference": "bf4aebd170fadf5fd808c70b90535de327e81a50"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/f734364e38a876a23be4d906a2a089e1315be18a",
|
||||
"reference": "f734364e38a876a23be4d906a2a089e1315be18a",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/bf4aebd170fadf5fd808c70b90535de327e81a50",
|
||||
"reference": "bf4aebd170fadf5fd808c70b90535de327e81a50",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -4094,6 +4094,7 @@
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"provide": {
|
||||
"php-http/message-factory-implementation": "1.0",
|
||||
"psr/http-factory-implementation": "1.0",
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
@ -4106,7 +4107,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
"dev-master": "1.6-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -4136,7 +4137,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Nyholm/psr7/issues",
|
||||
"source": "https://github.com/Nyholm/psr7/tree/1.5.1"
|
||||
"source": "https://github.com/Nyholm/psr7/tree/1.6.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -4148,7 +4149,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-06-22T07:13:36+00:00"
|
||||
"time": "2023-04-09T08:34:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/constant_time_encoding",
|
||||
|
@ -45,28 +45,32 @@ 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.');
|
||||
if (!Schema::hasColumn('rule_groups', 'description')) {
|
||||
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.');
|
||||
if (!Schema::hasColumn('rules', 'description')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,16 +38,18 @@ 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.');
|
||||
if (Schema::hasColumn('transactions', 'identifier')) {
|
||||
try {
|
||||
Schema::table(
|
||||
'transactions',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('identifier');
|
||||
}
|
||||
);
|
||||
} catch (QueryException|ColumnDoesNotExist $e) {
|
||||
Log::error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));
|
||||
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,16 +59,18 @@ 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.');
|
||||
if (!Schema::hasColumn('transactions', 'identifier')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,22 +46,24 @@ class ChangesForV410 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'notes',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('noteable_id', false, true);
|
||||
$table->string('noteable_type');
|
||||
$table->string('title')->nullable();
|
||||
$table->text('text')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "notes": %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.');
|
||||
if(!Schema::hasTable('notes')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'notes',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('noteable_id', false, true);
|
||||
$table->string('noteable_type');
|
||||
$table->string('title')->nullable();
|
||||
$table->text('text')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "notes": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,16 +37,18 @@ 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.');
|
||||
if (Schema::hasColumn('journal_meta', 'deleted_at')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,16 +58,18 @@ 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.');
|
||||
if (!Schema::hasColumn('journal_meta', 'deleted_at')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,26 +46,28 @@ class ChangesForV430 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'available_budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->integer('transaction_currency_id', false, true);
|
||||
$table->decimal('amount', 32, 12);
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
if (!Schema::hasTable('available_budgets')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'available_budgets',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->integer('transaction_currency_id', false, true);
|
||||
$table->decimal('amount', 32, 12);
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "available_budgets": %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.');
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "available_budgets": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,65 +39,74 @@ 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.');
|
||||
if (!Schema::hasColumn('budget_limits', '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.');
|
||||
if (!Schema::hasColumn('budget_limits', 'repeats')) {
|
||||
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.');
|
||||
if (Schema::hasColumn('budget_limits', 'start_date') && !Schema::hasColumn('budget_limits', '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.');
|
||||
if (Schema::hasColumn('budget_limits', '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.');
|
||||
if (Schema::hasColumn('transaction_currencies', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,66 +117,76 @@ 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.');
|
||||
if (!Schema::hasColumn('transaction_currencies', 'decimal_places')) {
|
||||
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.');
|
||||
if (Schema::hasColumn('budget_limits', 'startdate') && !Schema::hasColumn('budget_limits', '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.');
|
||||
if (!Schema::hasColumn('budget_limits', 'end_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.');
|
||||
if (Schema::hasColumn('budget_limits', 'repeats')) {
|
||||
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.');
|
||||
if (Schema::hasColumn('budget_limits', 'repeat_freq')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,20 +89,21 @@ class ChangesForV440 extends Migration
|
||||
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(
|
||||
'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');
|
||||
if(!Schema::hasColumn('transactions', 'transaction_currency_id')) {
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,16 +39,18 @@ 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.');
|
||||
if(Schema::hasColumn('transactions', 'foreign_amount')) {
|
||||
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 {
|
||||
@ -65,17 +67,18 @@ class ChangesForV450 extends Migration
|
||||
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.');
|
||||
if(Schema::hasColumn('transactions', 'foreign_currency_id')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,30 +89,34 @@ 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.');
|
||||
if(!Schema::hasColumn('transactions', 'foreign_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):
|
||||
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.');
|
||||
if(!Schema::hasColumn('transactions', 'foreign_currency_id')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,16 +39,18 @@ 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.');
|
||||
if (Schema::hasColumn('transactions', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,16 +60,18 @@ 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.');
|
||||
if (!Schema::hasColumn('transactions', 'reconciled')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,21 +47,23 @@ class CreateOauthAuthCodesTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_auth_codes',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id');
|
||||
$table->integer('client_id');
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_auth_codes": %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.');
|
||||
if(!Schema::hasTable('oauth_auth_codes')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_auth_codes',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id');
|
||||
$table->integer('client_id');
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_auth_codes": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,23 +47,25 @@ class CreateOauthAccessTokensTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_access_tokens',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id')->index()->nullable();
|
||||
$table->integer('client_id');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_access_tokens": %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.');
|
||||
if(!Schema::hasTable('oauth_access_tokens')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_access_tokens',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id')->index()->nullable();
|
||||
$table->integer('client_id');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_access_tokens": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,19 +47,21 @@ class CreateOauthRefreshTokensTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_refresh_tokens',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('access_token_id', 100)->index();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_refresh_tokens": %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.');
|
||||
if(!Schema::hasTable('oauth_refresh_tokens')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_refresh_tokens',
|
||||
static function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('access_token_id', 100)->index();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_refresh_tokens": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,24 +47,26 @@ class CreateOauthClientsTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->index()->nullable();
|
||||
$table->string('name');
|
||||
$table->string('secret', 100);
|
||||
$table->text('redirect');
|
||||
$table->boolean('personal_access_client');
|
||||
$table->boolean('password_client');
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_clients": %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.');
|
||||
if(!Schema::hasTable('oauth_clients')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->index()->nullable();
|
||||
$table->string('name');
|
||||
$table->string('secret', 100);
|
||||
$table->text('redirect');
|
||||
$table->boolean('personal_access_client');
|
||||
$table->boolean('password_client');
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_clients": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,18 +47,20 @@ class CreateOauthPersonalAccessClientsTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_personal_access_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('client_id')->index();
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_personal_access_clients": %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.');
|
||||
if(!Schema::hasTable('oauth_personal_access_clients')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'oauth_personal_access_clients',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('client_id')->index();
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "oauth_personal_access_clients": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,28 +41,32 @@ 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.');
|
||||
if(!Schema::hasColumn('attachments', 'notes')) {
|
||||
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.');
|
||||
if(Schema::hasColumn('transactions', 'order')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,28 +77,32 @@ 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.');
|
||||
if(Schema::hasColumn('attachments', '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.');
|
||||
}
|
||||
}
|
||||
|
||||
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.');
|
||||
if(!Schema::hasColumn('budgets', 'order')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,33 +42,36 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
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');
|
||||
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
if(!Schema::hasColumn('rules', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,28 +82,32 @@ class ChangesForV473 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
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.');
|
||||
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
|
||||
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.');
|
||||
if(!Schema::hasColumn('rules', 'strict')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,122 +54,133 @@ class ChangesForV475 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->integer('transaction_type_id', false, true);
|
||||
if (!Schema::hasTable('recurrences')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->integer('transaction_type_id', false, true);
|
||||
|
||||
$table->string('title', 1024);
|
||||
$table->text('description');
|
||||
$table->string('title', 1024);
|
||||
$table->text('description');
|
||||
|
||||
$table->date('first_date');
|
||||
$table->date('repeat_until')->nullable();
|
||||
$table->date('latest_date')->nullable();
|
||||
$table->smallInteger('repetitions', false, true);
|
||||
$table->date('first_date');
|
||||
$table->date('repeat_until')->nullable();
|
||||
$table->date('latest_date')->nullable();
|
||||
$table->smallInteger('repetitions', false, true);
|
||||
|
||||
$table->boolean('apply_rules')->default(true);
|
||||
$table->boolean('active')->default(true);
|
||||
$table->boolean('apply_rules')->default(true);
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
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.');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
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);
|
||||
if (!Schema::hasTable('recurrences_transactions')) {
|
||||
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');
|
||||
}
|
||||
);
|
||||
} 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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (!Schema::hasTable('recurrences_repetitions')) {
|
||||
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');
|
||||
}
|
||||
);
|
||||
} 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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::create(
|
||||
'recurrences_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('recurrence_id', false, true);
|
||||
if (!Schema::hasTable('recurrences_meta')) {
|
||||
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');
|
||||
}
|
||||
);
|
||||
} 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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
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');
|
||||
if (!Schema::hasTable('rt_meta')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'rt_meta',
|
||||
static function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('rt_id', false, true);
|
||||
|
||||
$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.');
|
||||
$table->string('name', 50);
|
||||
$table->text('value');
|
||||
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,21 +41,23 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
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');
|
||||
}
|
||||
if(Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
|
||||
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']);
|
||||
}
|
||||
);
|
||||
} 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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,17 +68,19 @@ class ChangesForV477 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
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.');
|
||||
if(!Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +41,18 @@ 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.');
|
||||
if(Schema::hasColumn('transaction_currencies', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,16 +63,18 @@ 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.');
|
||||
if(!Schema::hasColumn('transaction_currencies', 'enabled')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +41,18 @@ 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.');
|
||||
if(Schema::hasColumn('users', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,16 +67,18 @@ 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.');
|
||||
if(!Schema::hasColumn('users', 'objectguid')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,65 +40,74 @@ 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')) {
|
||||
// remove group ID
|
||||
if(Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
|
||||
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->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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
// remove 'stop processing' column
|
||||
if(Schema::hasColumn('rule_groups', 'stop_processing')) {
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
// remove 'mfa_secret' column
|
||||
if(Schema::hasColumn('users', 'mfa_secret')) {
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,52 +118,63 @@ class ChangesForV480 extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::table(
|
||||
'transaction_journals',
|
||||
static function (Blueprint $table) {
|
||||
$table->integer('transaction_currency_id', false, true)->nullable()->change();
|
||||
// add currency_id
|
||||
if(!Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
|
||||
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"
|
||||
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.'
|
||||
);
|
||||
// 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.');
|
||||
);
|
||||
} 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.');
|
||||
|
||||
// add 'stop processing' column
|
||||
if(!Schema::hasColumn('rule_groups', 'stop_processing')) {
|
||||
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.');
|
||||
|
||||
// add 'mfa_secret' column
|
||||
if(!Schema::hasColumn('users', 'mfa_secret')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,25 +51,27 @@ class MakeLocationsTable extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create(
|
||||
'locations',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
if (!Schema::hasTable('locations')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'locations',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->integer('locatable_id', false, true);
|
||||
$table->string('locatable_type', 255);
|
||||
$table->integer('locatable_id', false, true);
|
||||
$table->string('locatable_type', 255);
|
||||
|
||||
$table->decimal('latitude', 12, 8)->nullable();
|
||||
$table->decimal('longitude', 12, 8)->nullable();
|
||||
$table->smallInteger('zoom_level', false, true)->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "locations": %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.');
|
||||
$table->decimal('latitude', 12, 8)->nullable();
|
||||
$table->decimal('longitude', 12, 8)->nullable();
|
||||
$table->smallInteger('zoom_level', false, true)->nullable();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "locations": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,16 +42,18 @@ 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.');
|
||||
if(Schema::hasColumn('bills', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,16 +64,18 @@ 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.');
|
||||
if(!Schema::hasColumn('bills', 'order')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,42 +42,47 @@ 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.');
|
||||
if(Schema::hasColumn('oauth_clients', '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.');
|
||||
}
|
||||
}
|
||||
|
||||
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.');
|
||||
if(Schema::hasColumn('accounts', '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.');
|
||||
}
|
||||
}
|
||||
if(Schema::hasColumn('bills', 'end_date') && Schema::hasColumn('bills', 'extension_date')) {
|
||||
try {
|
||||
Schema::table(
|
||||
'bills',
|
||||
static function (Blueprint $table) {
|
||||
$table->dropColumn('end_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.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,40 +93,49 @@ 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.');
|
||||
if(!Schema::hasColumn('accounts', 'order')) {
|
||||
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.');
|
||||
|
||||
if(!Schema::hasColumn('oauth_clients', 'provider')) {
|
||||
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.');
|
||||
|
||||
if(!Schema::hasColumn('bills', 'end_date') && !Schema::hasColumn('bills', 'extension_date')) {
|
||||
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:
|
||||
try {
|
||||
Schema::table(
|
||||
|
@ -43,57 +43,65 @@ class ChangesForV550 extends Migration
|
||||
// recreate jobs table.
|
||||
Schema::dropIfExists('jobs');
|
||||
|
||||
try {
|
||||
Schema::create(
|
||||
'jobs',
|
||||
static function (Blueprint $table) {
|
||||
// straight from Laravel (this is the OLD table)
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->tinyInteger('reserved')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
$table->index(['queue', 'reserved', 'reserved_at']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "jobs": %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.');
|
||||
if (!Schema::hasTable('jobs')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'jobs',
|
||||
static function (Blueprint $table) {
|
||||
// straight from Laravel (this is the OLD table)
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->tinyInteger('reserved')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
$table->index(['queue', 'reserved', 'reserved_at']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "jobs": %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.');
|
||||
}
|
||||
}
|
||||
|
||||
// expand budget / transaction journal table.
|
||||
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.');
|
||||
if(Schema::hasColumn('budget_transaction_journal', '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
|
||||
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.');
|
||||
if(Schema::hasColumn('budget_limits', 'period') && Schema::hasColumn('budget_limits', '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.');
|
||||
}
|
||||
}
|
||||
|
||||
// drop other tables
|
||||
Schema::dropIfExists('webhook_attempts');
|
||||
Schema::dropIfExists('webhook_messages');
|
||||
Schema::dropIfExists('webhooks');
|
||||
@ -109,63 +117,70 @@ class ChangesForV550 extends Migration
|
||||
// drop and recreate jobs table.
|
||||
Schema::dropIfExists('jobs');
|
||||
// this is the NEW table
|
||||
try {
|
||||
Schema::create(
|
||||
'jobs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "jobs": %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.');
|
||||
if (!Schema::hasTable('jobs')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'jobs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "jobs": %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.');
|
||||
}
|
||||
}
|
||||
// drop failed jobs table.
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
|
||||
// create new failed_jobs table.
|
||||
try {
|
||||
Schema::create(
|
||||
'failed_jobs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "failed_jobs": %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.');
|
||||
if (!Schema::hasTable('failed_jobs')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'failed_jobs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "failed_jobs": %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.');
|
||||
}
|
||||
}
|
||||
|
||||
// update budget / transaction journal table.
|
||||
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');
|
||||
if(!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
|
||||
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.');
|
||||
);
|
||||
} 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.
|
||||
// I swear I dropped & recreated this field 15 times already.
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'budget_limits',
|
||||
|
@ -40,19 +40,21 @@ class ChangesForV550b2 extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
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');
|
||||
if(Schema::hasColumn('recurrences_transactions', '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.');
|
||||
);
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,19 +66,21 @@ class ChangesForV550b2 extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// expand recurrence transaction table
|
||||
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');
|
||||
if(!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
|
||||
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.');
|
||||
);
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,18 @@ 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.');
|
||||
if(Schema::hasColumn('users', '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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,16 +55,18 @@ 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.');
|
||||
if(!Schema::hasColumn('users', 'domain')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,12 +60,31 @@ class UserGroups extends Migration
|
||||
// remove columns from tables
|
||||
/** @var string $tableName */
|
||||
foreach ($this->tables as $tableName) {
|
||||
if (Schema::hasColumn($tableName, 'user_group_id')) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('users', 'user_group_id')) {
|
||||
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');
|
||||
}
|
||||
}
|
||||
@ -76,21 +95,6 @@ class UserGroups extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Schema::table(
|
||||
'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::dropIfExists('group_memberships');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('user_groups');
|
||||
@ -107,59 +111,64 @@ class UserGroups extends Migration
|
||||
* user is a member of a user_group through a user_group_role
|
||||
* may have multiple roles in a group
|
||||
*/
|
||||
try {
|
||||
Schema::create(
|
||||
'user_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
if (!Schema::hasTable('user_groups')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'user_groups',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->string('title', 255);
|
||||
$table->unique('title');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "user_groups": %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.');
|
||||
$table->string('title', 255);
|
||||
$table->unique('title');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "user_groups": %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(
|
||||
'user_roles',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
if (!Schema::hasTable('user_roles')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'user_roles',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->string('title', 255);
|
||||
$table->unique('title');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "user_roles": %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.');
|
||||
$table->string('title', 255);
|
||||
$table->unique('title');
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "user_roles": %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.');
|
||||
}
|
||||
}
|
||||
if (!Schema::hasTable('group_memberships')) {
|
||||
try {
|
||||
Schema::create(
|
||||
'group_memberships',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->bigInteger('user_group_id', false, true);
|
||||
$table->bigInteger('user_role_id', false, true);
|
||||
|
||||
try {
|
||||
Schema::create(
|
||||
'group_memberships',
|
||||
static function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->bigInteger('user_group_id', false, true);
|
||||
$table->bigInteger('user_role_id', false, true);
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'user_group_id', 'user_role_id']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
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.');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->unique(['user_id', 'user_group_id', 'user_role_id']);
|
||||
}
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
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(
|
||||
@ -167,7 +176,9 @@ class UserGroups extends Migration
|
||||
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');
|
||||
$table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate(
|
||||
'cascade'
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -175,7 +186,6 @@ class UserGroups extends Migration
|
||||
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) {
|
||||
|
@ -36,18 +36,20 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "notifications": %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.');
|
||||
if (!Schema::hasTable('notifications')) {
|
||||
try {
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "notifications": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,20 +36,22 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create('invited_users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->string('email', 255);
|
||||
$table->string('invite_code', 64);
|
||||
$table->dateTime('expires');
|
||||
$table->boolean('redeemed');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "invited_users": %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.');
|
||||
if (!Schema::hasTable('invited_users')) {
|
||||
try {
|
||||
Schema::create('invited_users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->integer('user_id', false, true);
|
||||
$table->string('email', 255);
|
||||
$table->string('invite_code', 64);
|
||||
$table->dateTime('expires');
|
||||
$table->boolean('redeemed');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "invited_users": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,25 +36,27 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
Schema::create('audit_log_entries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
if (!Schema::hasTable('audit_log_entries')) {
|
||||
try {
|
||||
Schema::create('audit_log_entries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->integer('auditable_id', false, true);
|
||||
$table->string('auditable_type');
|
||||
$table->integer('auditable_id', false, true);
|
||||
$table->string('auditable_type');
|
||||
|
||||
$table->integer('changer_id', false, true);
|
||||
$table->string('changer_type');
|
||||
$table->integer('changer_id', false, true);
|
||||
$table->string('changer_type');
|
||||
|
||||
$table->string('action', 255);
|
||||
$table->text('before')->nullable();
|
||||
$table->text('after')->nullable();
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "audit_log_entries": %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.');
|
||||
$table->string('action', 255);
|
||||
$table->text('before')->nullable();
|
||||
$table->text('after')->nullable();
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not create table "audit_log_entries": %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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user