mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Database stuff.
This commit is contained in:
parent
51d97cdca5
commit
b4f18dbe77
@ -225,7 +225,7 @@ class TestData
|
||||
Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
|
||||
|
||||
// some empty budgets.
|
||||
foreach (['A', 'B', 'C', 'D', 'E'] as $letter) {
|
||||
foreach (['A'] as $letter) {
|
||||
Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]);
|
||||
}
|
||||
|
||||
|
39
database/migrations/2016_04_25_093451_changes_for_385.php
Normal file
39
database/migrations/2016_04_25_093451_changes_for_385.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ChangesFor385 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// remove an index.
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropUnique('unique_limit');
|
||||
}
|
||||
);
|
||||
|
||||
// create it again, correctly.
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate','repeat_freq'], 'unique_limit');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Support\Migration\TestData;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@ -90,5 +91,25 @@ class TestDataSeeder extends Seeder
|
||||
|
||||
$current->addMonth();
|
||||
}
|
||||
|
||||
// create some special budget limits to test stuff with multiple budget limits
|
||||
// for a range of dates:
|
||||
$this->end->startOfMonth();
|
||||
$budget = TestData::findBudget($user, 'Bills');
|
||||
$ranges = ['daily','weekly','monthly','quarterly','half-year','yearly'];
|
||||
foreach($ranges as $range) {
|
||||
BudgetLimit::create(
|
||||
[
|
||||
'budget_id' => $budget->id,
|
||||
'startdate' => $this->end->format('Y-m-d'),
|
||||
'amount' => rand(100,200),
|
||||
'repeats' => 0,
|
||||
'repeat_freq' => $range,
|
||||
]
|
||||
);
|
||||
$this->end->addDay();
|
||||
}
|
||||
|
||||
// b
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user