mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Catch errors in DB seeds.
This commit is contained in:
parent
474e066d4a
commit
a80f083b6e
@ -30,15 +30,24 @@ class AccountTypeSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
AccountType::create(['type' => AccountType::DEFAULT]);
|
$types = [
|
||||||
AccountType::create(['type' => AccountType::CASH]);
|
AccountType::DEFAULT,
|
||||||
AccountType::create(['type' => AccountType::ASSET]);
|
AccountType::CASH,
|
||||||
AccountType::create(['type' => AccountType::EXPENSE]);
|
AccountType::ASSET,
|
||||||
AccountType::create(['type' => AccountType::REVENUE]);
|
AccountType::EXPENSE,
|
||||||
AccountType::create(['type' => AccountType::INITIAL_BALANCE]);
|
AccountType::REVENUE,
|
||||||
AccountType::create(['type' => AccountType::BENEFICIARY]);
|
AccountType::INITIAL_BALANCE,
|
||||||
AccountType::create(['type' => AccountType::IMPORT]);
|
AccountType::BENEFICIARY,
|
||||||
AccountType::create(['type' => AccountType::LOAN]);
|
AccountType::IMPORT,
|
||||||
AccountType::create(['type' => AccountType::RECONCILIATION]);
|
AccountType::LOAN,
|
||||||
|
AccountType::RECONCILIATION,
|
||||||
|
];
|
||||||
|
foreach ($types as $type) {
|
||||||
|
try {
|
||||||
|
AccountType::create(['type' => $type]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
Log::warning(sprintf('Could not create account type "%s". It might exist already.', $type));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY, without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
@ -33,32 +33,38 @@ class LinkTypeSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$link = new LinkType;
|
$types = [
|
||||||
$link->name = 'Related';
|
[
|
||||||
$link->inward = 'relates to';
|
'name' => 'Related',
|
||||||
$link->outward = 'relates to';
|
'inward' => 'relates to',
|
||||||
$link->editable = false;
|
'outward' => 'relates to',
|
||||||
$link->save();
|
'editable' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Refund',
|
||||||
|
'inward' => 'is (partially) refunded by',
|
||||||
|
'outward' => '(partially) refunds',
|
||||||
|
'editable' => false,
|
||||||
|
],
|
||||||
|
['name' => 'Paid',
|
||||||
|
'inward' => 'is (partially) paid for by',
|
||||||
|
'outward' => '(partially) pays for',
|
||||||
|
'editable' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Reimbursement',
|
||||||
|
'inward' => 'is (partially) reimbursed by',
|
||||||
|
'outward' => '(partially) reimburses',
|
||||||
|
'editable' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
foreach ($types as $type) {
|
||||||
|
try {
|
||||||
|
LinkType::create($type);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
Log::warning(sprintf('Could not create link type "%s". It might exist already.', $type['name']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$link = new LinkType;
|
|
||||||
$link->name = 'Refund';
|
|
||||||
$link->inward = 'is (partially) refunded by';
|
|
||||||
$link->outward = '(partially) refunds';
|
|
||||||
$link->editable = false;
|
|
||||||
$link->save();
|
|
||||||
|
|
||||||
$link = new LinkType;
|
|
||||||
$link->name = 'Paid';
|
|
||||||
$link->inward = 'is (partially) paid for by';
|
|
||||||
$link->outward = '(partially) pays for';
|
|
||||||
$link->editable = false;
|
|
||||||
$link->save();
|
|
||||||
|
|
||||||
$link = new LinkType;
|
|
||||||
$link->name = 'Reimbursement';
|
|
||||||
$link->inward = 'is (partially) reimbursed by';
|
|
||||||
$link->outward = '(partially) reimburses';
|
|
||||||
$link->editable = false;
|
|
||||||
$link->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,25 @@ class PermissionSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$owner = new Role;
|
$roles = [
|
||||||
$owner->name = 'owner';
|
[
|
||||||
$owner->display_name = 'Site Owner';
|
'name' => 'owner',
|
||||||
$owner->description = 'User runs this instance of FF3'; // optional
|
'display_name' => 'Site Owner',
|
||||||
$owner->save();
|
'description' => 'User runs this instance of FF3',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'demo',
|
||||||
|
'display_name' => 'Demo User',
|
||||||
|
'description' => 'User is a demo user',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
try {
|
||||||
|
Role::create($role);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
Log::warning(sprintf('Could not create role "%s". It might exist already.', $role['display_name']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$demo = new Role;
|
|
||||||
$demo->name = 'demo';
|
|
||||||
$demo->display_name = 'Demo User';
|
|
||||||
$demo->description = 'User is a demo user';
|
|
||||||
$demo->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,34 +30,43 @@ class TransactionCurrencySeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$currencies = [];
|
||||||
// european currencies
|
// european currencies
|
||||||
TransactionCurrency::create(['code' => 'EUR', 'name' => 'Euro', 'symbol' => '€', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'EUR', 'name' => 'Euro', 'symbol' => '€', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'HUF', 'name' => 'Hungarian forint', 'symbol' => 'Ft', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'HUF', 'name' => 'Hungarian forint', 'symbol' => 'Ft', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'GBP', 'name' => 'British Pound', 'symbol' => '£', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'GBP', 'name' => 'British Pound', 'symbol' => '£', 'decimal_places' => 2];
|
||||||
|
|
||||||
// american currencies
|
// american currencies
|
||||||
TransactionCurrency::create(['code' => 'USD', 'name' => 'US Dollar', 'symbol' => '$', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'USD', 'name' => 'US Dollar', 'symbol' => '$', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'BRL', 'name' => 'Brazilian real', 'symbol' => 'R$', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'BRL', 'name' => 'Brazilian real', 'symbol' => 'R$', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'CAD', 'name' => 'Canadian dollar', 'symbol' => 'C$', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'CAD', 'name' => 'Canadian dollar', 'symbol' => 'C$', 'decimal_places' => 2];
|
||||||
|
|
||||||
// oceanian currencies
|
// oceanian currencies
|
||||||
TransactionCurrency::create(['code' => 'IDR', 'name' => 'Indonesian rupiah', 'symbol' => 'Rp', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'IDR', 'name' => 'Indonesian rupiah', 'symbol' => 'Rp', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'AUD', 'name' => 'Australian dollar', 'symbol' => 'A$', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'AUD', 'name' => 'Australian dollar', 'symbol' => 'A$', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'NZD', 'name' => 'New Zealand dollar', 'symbol' => 'NZ$', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'NZD', 'name' => 'New Zealand dollar', 'symbol' => 'NZ$', 'decimal_places' => 2];
|
||||||
|
|
||||||
// african currencies
|
// african currencies
|
||||||
TransactionCurrency::create(['code' => 'EGP', 'name' => 'Egyptian pound', 'symbol' => 'E£', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'EGP', 'name' => 'Egyptian pound', 'symbol' => 'E£', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'MAD', 'name' => 'Moroccan dirham', 'symbol' => 'DH', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'MAD', 'name' => 'Moroccan dirham', 'symbol' => 'DH', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'ZAR', 'name' => 'South African rand', 'symbol' => 'R', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'ZAR', 'name' => 'South African rand', 'symbol' => 'R', 'decimal_places' => 2];
|
||||||
|
|
||||||
// asian currencies
|
// asian currencies
|
||||||
TransactionCurrency::create(['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'RMB', 'name' => 'Chinese yuan', 'symbol' => '元', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'RMB', 'name' => 'Chinese yuan', 'symbol' => '元', 'decimal_places' => 2];
|
||||||
TransactionCurrency::create(['code' => 'RUB', 'name' => 'Russian ruble ', 'symbol' => '₽', 'decimal_places' => 2]);
|
$currencies[] = ['code' => 'RUB', 'name' => 'Russian ruble ', 'symbol' => '₽', 'decimal_places' => 2];
|
||||||
|
|
||||||
// international currencies
|
// international currencies
|
||||||
TransactionCurrency::create(['code' => 'XBT', 'name' => 'Bitcoin', 'symbol' => '₿', 'decimal_places' => 8]);
|
$currencies[] = ['code' => 'XBT', 'name' => 'Bitcoin', 'symbol' => '₿', 'decimal_places' => 8];
|
||||||
TransactionCurrency::create(['code' => 'BCH', 'name' => 'Bitcoin cash', 'symbol' => '₿C', 'decimal_places' => 8]);
|
$currencies[] = ['code' => 'BCH', 'name' => 'Bitcoin cash', 'symbol' => '₿C', 'decimal_places' => 8];
|
||||||
TransactionCurrency::create(['code' => 'ETH', 'name' => 'Ethereum', 'symbol' => 'Ξ', 'decimal_places' => 12]);
|
$currencies[] = ['code' => 'ETH', 'name' => 'Ethereum', 'symbol' => 'Ξ', 'decimal_places' => 12];
|
||||||
|
|
||||||
|
foreach ($currencies as $currency) {
|
||||||
|
try {
|
||||||
|
TransactionCurrency::create($currency);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
Log::warning(sprintf('Could not create transaction currency "%s". It might exist already.', $currency['code']));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,20 @@ class TransactionTypeSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
TransactionType::create(['type' => TransactionType::WITHDRAWAL]);
|
$types = [
|
||||||
TransactionType::create(['type' => TransactionType::DEPOSIT]);
|
TransactionType::WITHDRAWAL,
|
||||||
TransactionType::create(['type' => TransactionType::TRANSFER]);
|
TransactionType::DEPOSIT,
|
||||||
TransactionType::create(['type' => TransactionType::OPENING_BALANCE]);
|
TransactionType::TRANSFER,
|
||||||
TransactionType::create(['type' => TransactionType::RECONCILIATION]);
|
TransactionType::OPENING_BALANCE,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
try {
|
||||||
|
TransactionType::create(['type' => $type]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
Log::warning(sprintf('Could not create transaction type "%s". It might exist already.', $type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user