Cast fields to string and drop unused table.

This commit is contained in:
James Cole
2024-11-15 19:13:37 +01:00
parent ec89a2f956
commit 60f6a91fe4
12 changed files with 17 additions and 19 deletions

View File

@@ -57,6 +57,7 @@ class Account extends Model
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'active' => 'boolean', 'active' => 'boolean',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
'virtual_balance' => 'string',
]; ];
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban']; protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];

View File

@@ -21,6 +21,7 @@ class AccountBalance extends Model
{ {
return [ return [
'date' => SeparateTimezoneCaster::class, 'date' => SeparateTimezoneCaster::class,
'balance' => 'string',
]; ];
} }

View File

@@ -49,6 +49,10 @@ class AutoBudget extends Model
public const int AUTO_BUDGET_ROLLOVER = 2; public const int AUTO_BUDGET_ROLLOVER = 2;
protected $fillable = ['budget_id', 'amount', 'period']; protected $fillable = ['budget_id', 'amount', 'period'];
protected $casts = [
'amount' => 'string',
];
public function budget(): BelongsTo public function budget(): BelongsTo
{ {
return $this->belongsTo(Budget::class); return $this->belongsTo(Budget::class);

View File

@@ -49,6 +49,7 @@ class AvailableBudget extends Model
'start_date' => 'date', 'start_date' => 'date',
'end_date' => 'date', 'end_date' => 'date',
'transaction_currency_id' => 'int', 'transaction_currency_id' => 'int',
'amount' => 'string',
]; ];
protected $fillable = ['user_id', 'user_group_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date', 'start_date_tz', 'end_date_tz']; protected $fillable = ['user_id', 'user_group_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date', 'start_date_tz', 'end_date_tz'];

View File

@@ -58,6 +58,8 @@ class Bill extends Model
'active' => 'boolean', 'active' => 'boolean',
'name_encrypted' => 'boolean', 'name_encrypted' => 'boolean',
'match_encrypted' => 'boolean', 'match_encrypted' => 'boolean',
'amount_min' => 'string',
'amount_max' => 'string',
]; ];
protected $fillable protected $fillable

View File

@@ -47,6 +47,7 @@ class BudgetLimit extends Model
'start_date' => SeparateTimezoneCaster::class, 'start_date' => SeparateTimezoneCaster::class,
'end_date' => SeparateTimezoneCaster::class, 'end_date' => SeparateTimezoneCaster::class,
'auto_budget' => 'boolean', 'auto_budget' => 'boolean',
'amount' => 'string',
]; ];
protected $dispatchesEvents protected $dispatchesEvents
= [ = [

View File

@@ -49,6 +49,8 @@ class CurrencyExchangeRate extends Model
'from_currency_id' => 'int', 'from_currency_id' => 'int',
'to_currency_id' => 'int', 'to_currency_id' => 'int',
'date' => SeparateTimezoneCaster::class, 'date' => SeparateTimezoneCaster::class,
'rate' => 'string',
'user_rate' => 'string',
]; ];
protected $fillable = ['user_id', 'from_currency_id', 'to_currency_id', 'date', 'date_tz', 'rate']; protected $fillable = ['user_id', 'from_currency_id', 'to_currency_id', 'date', 'date_tz', 'rate'];

View File

@@ -51,6 +51,7 @@ class PiggyBank extends Model
'order' => 'int', 'order' => 'int',
'active' => 'boolean', 'active' => 'boolean',
'encrypted' => 'boolean', 'encrypted' => 'boolean',
'targetamount' => 'string',
]; ];
protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'startdate_tz', 'targetdate', 'targetdate_tz', 'active']; protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'startdate_tz', 'targetdate', 'targetdate_tz', 'active'];

View File

@@ -41,6 +41,7 @@ class PiggyBankEvent extends Model
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'date' => SeparateTimezoneCaster::class, 'date' => SeparateTimezoneCaster::class,
'amount' => 'string',
]; ];
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount']; protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount'];

View File

@@ -44,6 +44,7 @@ class PiggyBankRepetition extends Model
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'startdate' => SeparateTimezoneCaster::class, 'startdate' => SeparateTimezoneCaster::class,
'targetdate' => SeparateTimezoneCaster::class, 'targetdate' => SeparateTimezoneCaster::class,
'virtual_balance' => 'string',
]; ];
protected $fillable = ['piggy_bank_id', 'startdate', 'startdate_tz', 'targetdate', 'targetdate_tz', 'currentamount']; protected $fillable = ['piggy_bank_id', 'startdate', 'startdate_tz', 'targetdate', 'targetdate_tz', 'currentamount'];

View File

@@ -57,6 +57,8 @@ class Transaction extends Model
'balance_before' => 'string', 'balance_before' => 'string',
'balance_after' => 'string', 'balance_after' => 'string',
'date' => 'datetime', 'date' => 'datetime',
'amount' => 'string',
'foreign_amount' => 'string',
]; ];
protected $fillable protected $fillable

View File

@@ -294,25 +294,6 @@ class CreateMainTables extends Migration
app('log')->error(self::TABLE_ALREADY_EXISTS); app('log')->error(self::TABLE_ALREADY_EXISTS);
} }
} }
if (!Schema::hasTable('limit_repetitions')) {
try {
Schema::create(
'limit_repetitions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('budget_limit_id', false, true);
$table->date('startdate');
$table->date('enddate');
$table->decimal('amount', 32, 12);
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
}
);
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'limit_repetitions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
}
}
} }
private function createCategoriesTable(): void private function createCategoriesTable(): void