Skip to content

Firefly III: a personal finances manager

Database stuff.

James Coleb4f18dbe7741
diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php
index 66f22d01c2..b79ef52e2c 100644
--- a/app/Support/Migration/TestData.php
+++ b/app/Support/Migration/TestData.php
@@ -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]);
}
diff --git a/database/migrations/2016_04_25_093451_changes_for_385.php b/database/migrations/2016_04_25_093451_changes_for_385.php
new file mode 100644
index 0000000000..94d87cbd9f
--- /dev/null
+++ b/database/migrations/2016_04_25_093451_changes_for_385.php
@@ -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()
+ {
+ //
+ }
+}
diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php
index f018ad6b6e..ed6151f9e2 100644
--- a/database/seeds/TestDataSeeder.php
+++ b/database/seeds/TestDataSeeder.php
@@ -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
}
}