Merge pull request #7353 from firefly-iii/migration-checks

Catch all possible migration errors
This commit is contained in:
James Cole 2023-04-10 08:29:49 +02:00 committed by GitHub
commit b91e019416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 1213 additions and 1035 deletions

View File

@ -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.
*

View File

@ -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
View File

@ -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",

View File

@ -45,6 +45,7 @@ class FixNullables extends Migration
*/
public function up(): void
{
if (!Schema::hasColumn('rule_groups', 'description')) {
try {
Schema::table(
'rule_groups',
@ -56,7 +57,9 @@ class FixNullables extends Migration
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('rules', 'description')) {
try {
Schema::table(
'rules',
@ -69,4 +72,5 @@ class FixNullables extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -38,6 +38,7 @@ class ExpandTransactionsTable extends Migration
*/
public function down(): void
{
if (Schema::hasColumn('transactions', 'identifier')) {
try {
Schema::table(
'transactions',
@ -46,10 +47,11 @@ class ExpandTransactionsTable extends Migration
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column "extended_status": %s', $e->getMessage()));
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.');
}
}
}
/**
* Run the migrations.
@ -57,6 +59,7 @@ class ExpandTransactionsTable extends Migration
*/
public function up(): void
{
if (!Schema::hasColumn('transactions', 'identifier')) {
try {
Schema::table(
'transactions',
@ -69,4 +72,5 @@ class ExpandTransactionsTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -46,6 +46,7 @@ class ChangesForV410 extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('notes')) {
try {
Schema::create(
'notes',
@ -64,4 +65,5 @@ class ChangesForV410 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.');
}
}
}
}

View File

@ -37,6 +37,7 @@ class ChangesForV420 extends Migration
*/
public function down(): void
{
if (Schema::hasColumn('journal_meta', 'deleted_at')) {
try {
Schema::table(
'journal_meta',
@ -49,6 +50,7 @@ class ChangesForV420 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -56,6 +58,7 @@ class ChangesForV420 extends Migration
*/
public function up(): void
{
if (!Schema::hasColumn('journal_meta', 'deleted_at')) {
try {
Schema::table(
'journal_meta',
@ -68,4 +71,5 @@ class ChangesForV420 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -46,6 +46,7 @@ class ChangesForV430 extends Migration
*/
public function up(): void
{
if (!Schema::hasTable('available_budgets')) {
try {
Schema::create(
'available_budgets',
@ -68,4 +69,5 @@ class ChangesForV430 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.');
}
}
}
}

View File

@ -39,6 +39,7 @@ class ChangesForV431 extends Migration
public function down(): void
{
// reinstate "repeats" and "repeat_freq".
if (!Schema::hasColumn('budget_limits', 'repeat_freq')) {
try {
Schema::table(
'budget_limits',
@ -50,6 +51,8 @@ class ChangesForV431 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.');
}
}
if (!Schema::hasColumn('budget_limits', 'repeats')) {
try {
Schema::table(
'budget_limits',
@ -61,8 +64,9 @@ class ChangesForV431 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.');
}
}
// change field "start_date" to "startdate"
if (Schema::hasColumn('budget_limits', 'start_date') && !Schema::hasColumn('budget_limits', 'startdate')) {
try {
Schema::table(
'budget_limits',
@ -74,8 +78,10 @@ class ChangesForV431 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.');
}
}
// remove date field "end_date"
if (Schema::hasColumn('budget_limits', 'end_date')) {
try {
Schema::table(
'budget_limits',
@ -87,7 +93,9 @@ class ChangesForV431 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.');
}
}
// remove decimal places
if (Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try {
Schema::table(
'transaction_currencies',
@ -100,6 +108,7 @@ class ChangesForV431 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -108,6 +117,7 @@ class ChangesForV431 extends Migration
public function up(): void
{
// add decimal places to "transaction currencies".
if (!Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try {
Schema::table(
'transaction_currencies',
@ -119,8 +129,10 @@ class ChangesForV431 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.');
}
}
// change field "startdate" to "start_date"
if (Schema::hasColumn('budget_limits', 'startdate') && !Schema::hasColumn('budget_limits', 'start_date')) {
try {
Schema::table(
'budget_limits',
@ -132,8 +144,10 @@ class ChangesForV431 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 date field "end_date" after "start_date"
if (!Schema::hasColumn('budget_limits', 'end_date')) {
try {
Schema::table(
'budget_limits',
@ -145,8 +159,10 @@ class ChangesForV431 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.');
}
}
// drop "repeats" and "repeat_freq".
if (Schema::hasColumn('budget_limits', 'repeats')) {
try {
Schema::table(
'budget_limits',
@ -158,6 +174,8 @@ class ChangesForV431 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.');
}
}
if (Schema::hasColumn('budget_limits', 'repeat_freq')) {
try {
Schema::table(
'budget_limits',
@ -170,4 +188,5 @@ class ChangesForV431 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -89,7 +89,7 @@ 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.');
}
}
if(!Schema::hasColumn('transactions', 'transaction_currency_id')) {
try {
Schema::table(
'transactions',
@ -105,4 +105,5 @@ class ChangesForV440 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -39,6 +39,7 @@ class ChangesForV450 extends Migration
public function down(): void
{
// split up for sqlite compatibility
if(Schema::hasColumn('transactions', 'foreign_amount')) {
try {
Schema::table(
'transactions',
@ -50,6 +51,7 @@ 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(
@ -65,7 +67,7 @@ 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.');
}
if(Schema::hasColumn('transactions', 'foreign_currency_id')) {
try {
Schema::table(
'transactions',
@ -78,6 +80,7 @@ class ChangesForV450 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -86,6 +89,7 @@ class ChangesForV450 extends Migration
public function up(): void
{
// add "foreign_amount" to transactions
if(!Schema::hasColumn('transactions', 'foreign_amount')) {
try {
Schema::table(
'transactions',
@ -97,8 +101,10 @@ 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.');
}
}
// add foreign transaction currency id to transactions (is nullable):
if(!Schema::hasColumn('transactions', 'foreign_currency_id')) {
try {
Schema::table(
'transactions',
@ -112,4 +118,5 @@ class ChangesForV450 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -39,6 +39,7 @@ class ChangesForV470a extends Migration
*/
public function down(): void
{
if (Schema::hasColumn('transactions', 'reconciled')) {
try {
Schema::table(
'transactions',
@ -51,6 +52,7 @@ class ChangesForV470a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -58,6 +60,7 @@ class ChangesForV470a extends Migration
*/
public function up(): void
{
if (!Schema::hasColumn('transactions', 'reconciled')) {
try {
Schema::table(
'transactions',
@ -70,4 +73,5 @@ class ChangesForV470a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -47,6 +47,7 @@ class CreateOauthAuthCodesTable extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('oauth_auth_codes')) {
try {
Schema::create(
'oauth_auth_codes',
@ -64,4 +65,5 @@ class CreateOauthAuthCodesTable 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.');
}
}
}
}

View File

@ -47,6 +47,7 @@ class CreateOauthAccessTokensTable extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('oauth_access_tokens')) {
try {
Schema::create(
'oauth_access_tokens',
@ -66,4 +67,5 @@ class CreateOauthAccessTokensTable 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.');
}
}
}
}

View File

@ -47,6 +47,7 @@ class CreateOauthRefreshTokensTable extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('oauth_refresh_tokens')) {
try {
Schema::create(
'oauth_refresh_tokens',
@ -62,4 +63,5 @@ class CreateOauthRefreshTokensTable 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.');
}
}
}
}

View File

@ -47,6 +47,7 @@ class CreateOauthClientsTable extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('oauth_clients')) {
try {
Schema::create(
'oauth_clients',
@ -67,4 +68,5 @@ class CreateOauthClientsTable 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.');
}
}
}
}

View File

@ -47,6 +47,7 @@ class CreateOauthPersonalAccessClientsTable extends Migration
*/
public function up(): void
{
if(!Schema::hasTable('oauth_personal_access_clients')) {
try {
Schema::create(
'oauth_personal_access_clients',
@ -61,4 +62,5 @@ class CreateOauthPersonalAccessClientsTable 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.');
}
}
}
}

View File

@ -41,6 +41,7 @@ class ChangesForV472 extends Migration
*/
public function down(): void
{
if(!Schema::hasColumn('attachments', 'notes')) {
try {
Schema::table(
'attachments',
@ -52,7 +53,9 @@ class ChangesForV472 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.');
}
}
if(Schema::hasColumn('transactions', 'order')) {
try {
Schema::table(
'budgets',
@ -65,6 +68,7 @@ class ChangesForV472 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -73,6 +77,7 @@ class ChangesForV472 extends Migration
*/
public function up(): void
{
if(Schema::hasColumn('attachments', 'notes')) {
try {
Schema::table(
'attachments',
@ -84,7 +89,9 @@ class ChangesForV472 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.');
}
}
if(!Schema::hasColumn('budgets', 'order')) {
try {
Schema::table(
'budgets',
@ -97,4 +104,5 @@ class ChangesForV472 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -42,6 +42,7 @@ class ChangesForV473 extends Migration
*/
public function down(): void
{
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
try {
Schema::table(
'bills',
@ -57,8 +58,9 @@ class ChangesForV473 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.');
}
}
if(!Schema::hasColumn('rules', 'strict')) {
try {
Schema::table(
'rules',
@ -71,6 +73,7 @@ class ChangesForV473 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -79,6 +82,7 @@ class ChangesForV473 extends Migration
*/
public function up(): void
{
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
try {
Schema::table(
'bills',
@ -91,6 +95,8 @@ class ChangesForV473 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.');
}
}
if(!Schema::hasColumn('rules', 'strict')) {
try {
Schema::table(
'rules',
@ -103,4 +109,5 @@ class ChangesForV473 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -54,6 +54,7 @@ class ChangesForV475 extends Migration
*/
public function up(): void
{
if (!Schema::hasTable('recurrences')) {
try {
Schema::create(
'recurrences',
@ -83,6 +84,8 @@ class ChangesForV475 extends Migration
Log::error(sprintf('Could not create table "recurrences": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
}
if (!Schema::hasTable('recurrences_transactions')) {
try {
Schema::create(
'recurrences_transactions',
@ -111,7 +114,9 @@ class ChangesForV475 extends Migration
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.');
}
}
if (!Schema::hasTable('recurrences_repetitions')) {
try {
Schema::create(
'recurrences_repetitions',
@ -132,7 +137,9 @@ class ChangesForV475 extends Migration
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.');
}
}
if (!Schema::hasTable('recurrences_meta')) {
try {
Schema::create(
'recurrences_meta',
@ -152,6 +159,9 @@ class ChangesForV475 extends Migration
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.');
}
}
if (!Schema::hasTable('rt_meta')) {
try {
Schema::create(
'rt_meta',
@ -172,4 +182,5 @@ class ChangesForV475 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.');
}
}
}
}

View File

@ -41,6 +41,7 @@ class ChangesForV477 extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try {
Schema::table(
'budget_limits',
@ -58,6 +59,7 @@ class ChangesForV477 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -66,6 +68,7 @@ class ChangesForV477 extends Migration
*/
public function up(): void
{
if(!Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try {
Schema::table(
'budget_limits',
@ -79,4 +82,5 @@ class ChangesForV477 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -41,6 +41,7 @@ class ChangesForV479 extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('transaction_currencies', 'enabled')) {
try {
Schema::table(
'transaction_currencies',
@ -53,6 +54,7 @@ class ChangesForV479 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -61,6 +63,7 @@ class ChangesForV479 extends Migration
*/
public function up(): void
{
if(!Schema::hasColumn('transaction_currencies', 'enabled')) {
try {
Schema::table(
'transaction_currencies',
@ -73,4 +76,5 @@ class ChangesForV479 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -41,6 +41,7 @@ class FixLdapConfiguration extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('users', 'objectguid')) {
try {
Schema::table(
'users',
@ -53,6 +54,7 @@ class FixLdapConfiguration extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -65,6 +67,7 @@ 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.
*/
if(!Schema::hasColumn('users', 'objectguid')) {
try {
Schema::table(
'users',
@ -77,4 +80,5 @@ class FixLdapConfiguration extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -40,6 +40,8 @@ class ChangesForV480 extends Migration
*/
public function down(): void
{
// remove group ID
if(Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try {
Schema::table(
'transaction_journals',
@ -66,7 +68,10 @@ class ChangesForV480 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.');
}
}
// remove 'stop processing' column
if(Schema::hasColumn('rule_groups', 'stop_processing')) {
try {
Schema::table(
'rule_groups',
@ -83,7 +88,10 @@ class ChangesForV480 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.');
}
}
// remove 'mfa_secret' column
if(Schema::hasColumn('users', 'mfa_secret')) {
try {
Schema::table(
'users',
@ -101,6 +109,7 @@ class ChangesForV480 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -109,6 +118,8 @@ class ChangesForV480 extends Migration
*/
public function up(): void
{
// add currency_id
if(!Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try {
Schema::table(
'transaction_journals',
@ -134,6 +145,10 @@ class ChangesForV480 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 'stop processing' column
if(!Schema::hasColumn('rule_groups', 'stop_processing')) {
try {
Schema::table(
'rule_groups',
@ -145,6 +160,10 @@ class ChangesForV480 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 'mfa_secret' column
if(!Schema::hasColumn('users', 'mfa_secret')) {
try {
Schema::table(
'users',
@ -157,4 +176,5 @@ class ChangesForV480 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -51,6 +51,7 @@ class MakeLocationsTable extends Migration
*/
public function up(): void
{
if (!Schema::hasTable('locations')) {
try {
Schema::create(
'locations',
@ -72,4 +73,5 @@ class MakeLocationsTable 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.');
}
}
}
}

View File

@ -42,6 +42,7 @@ class ChangesForV530a extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('bills', 'order')) {
try {
Schema::table(
'bills',
@ -54,6 +55,7 @@ class ChangesForV530a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -62,6 +64,7 @@ class ChangesForV530a extends Migration
*/
public function up(): void
{
if(!Schema::hasColumn('bills', 'order')) {
try {
Schema::table(
'bills',
@ -74,4 +77,5 @@ class ChangesForV530a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -42,6 +42,7 @@ class ChangesForV540 extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('oauth_clients', 'provider')) {
try {
Schema::table(
'oauth_clients',
@ -53,7 +54,9 @@ class ChangesForV540 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.');
}
}
if(Schema::hasColumn('accounts', 'order')) {
try {
Schema::table(
'accounts',
@ -65,7 +68,8 @@ class ChangesForV540 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.');
}
}
if(Schema::hasColumn('bills', 'end_date') && Schema::hasColumn('bills', 'extension_date')) {
try {
Schema::table(
'bills',
@ -80,6 +84,7 @@ class ChangesForV540 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -88,6 +93,7 @@ class ChangesForV540 extends Migration
*/
public function up(): void
{
if(!Schema::hasColumn('accounts', 'order')) {
try {
Schema::table(
'accounts',
@ -99,6 +105,9 @@ class ChangesForV540 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.');
}
}
if(!Schema::hasColumn('oauth_clients', 'provider')) {
try {
Schema::table(
'oauth_clients',
@ -110,6 +119,9 @@ class ChangesForV540 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.');
}
}
if(!Schema::hasColumn('bills', 'end_date') && !Schema::hasColumn('bills', 'extension_date')) {
try {
Schema::table(
'bills',
@ -122,6 +134,8 @@ class ChangesForV540 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.');
}
}
// make column nullable:
try {
Schema::table(

View File

@ -43,6 +43,7 @@ class ChangesForV550 extends Migration
// recreate jobs table.
Schema::dropIfExists('jobs');
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
@ -63,8 +64,10 @@ class ChangesForV550 extends Migration
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.
if(Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try {
Schema::table(
'budget_transaction_journal',
@ -77,11 +80,13 @@ class ChangesForV550 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.');
}
}
// drop failed jobs table.
Schema::dropIfExists('failed_jobs');
// drop fields from budget limits
if(Schema::hasColumn('budget_limits', 'period') && Schema::hasColumn('budget_limits', 'generated')) {
try {
Schema::table(
'budget_limits',
@ -94,6 +99,9 @@ class ChangesForV550 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.');
}
}
// drop other tables
Schema::dropIfExists('webhook_attempts');
Schema::dropIfExists('webhook_messages');
Schema::dropIfExists('webhooks');
@ -109,6 +117,7 @@ class ChangesForV550 extends Migration
// drop and recreate jobs table.
Schema::dropIfExists('jobs');
// this is the NEW table
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
@ -126,10 +135,12 @@ class ChangesForV550 extends Migration
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.
if (!Schema::hasTable('failed_jobs')) {
try {
Schema::create(
'failed_jobs',
@ -147,8 +158,10 @@ class ChangesForV550 extends Migration
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.
if(!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try {
Schema::table(
'budget_transaction_journal',
@ -163,9 +176,11 @@ class ChangesForV550 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.');
}
}
// 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',

View File

@ -40,6 +40,7 @@ class ChangesForV550b2 extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try {
Schema::table(
'recurrences_transactions',
@ -55,6 +56,7 @@ class ChangesForV550b2 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
@ -64,6 +66,7 @@ class ChangesForV550b2 extends Migration
public function up(): void
{
// expand recurrence transaction table
if(!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try {
Schema::table(
'recurrences_transactions',
@ -79,4 +82,5 @@ class ChangesForV550b2 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -35,6 +35,7 @@ class AddLdapColumnsToUsersTable extends Migration
*/
public function down(): void
{
if(Schema::hasColumn('users', 'domain')) {
try {
Schema::table(
'users',
@ -47,12 +48,14 @@ class AddLdapColumnsToUsersTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
/**
* Run the migrations.
*/
public function up(): void
{
if(!Schema::hasColumn('users', 'domain')) {
try {
Schema::table(
'users',
@ -65,4 +68,5 @@ class AddLdapColumnsToUsersTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}
}

View File

@ -60,6 +60,7 @@ 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,
@ -75,7 +76,9 @@ class UserGroups extends Migration
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(
'users',
@ -90,6 +93,7 @@ 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.');
}
}
Schema::dropIfExists('group_memberships');
Schema::dropIfExists('user_roles');
@ -107,6 +111,7 @@ class UserGroups extends Migration
* user is a member of a user_group through a user_group_role
* may have multiple roles in a group
*/
if (!Schema::hasTable('user_groups')) {
try {
Schema::create(
'user_groups',
@ -123,6 +128,8 @@ class UserGroups extends Migration
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.');
}
}
if (!Schema::hasTable('user_roles')) {
try {
Schema::create(
'user_roles',
@ -139,7 +146,8 @@ class UserGroups extends Migration
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',
@ -161,13 +169,16 @@ class UserGroups extends Migration
Log::error(sprintf('Could not create table "group_memberships": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
}
try {
Schema::table(
'users',
function (Blueprint $table) {
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) {

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/
public function up(): void
{
if (!Schema::hasTable('notifications')) {
try {
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
@ -50,6 +51,7 @@ return new class () 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.');
}
}
}
/**
* Reverse the migrations.

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/
public function up(): void
{
if (!Schema::hasTable('invited_users')) {
try {
Schema::create('invited_users', function (Blueprint $table) {
$table->id();
@ -52,6 +53,7 @@ return new class () 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.');
}
}
}
/**
* Reverse the migrations.

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/
public function up(): void
{
if (!Schema::hasTable('audit_log_entries')) {
try {
Schema::create('audit_log_entries', function (Blueprint $table) {
$table->id();
@ -57,6 +58,7 @@ return new class () 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.');
}
}
}
/**
* Reverse the migrations.