Skip to content

Firefly III: a personal finances manager

New migrations (also for export).

James Cole3bb107e192cd
diff --git a/database/migrations/2016_02_04_144117_changes_for_v380.php b/database/migrations/2016_02_04_144117_changes_for_v380.php
new file mode 100644
index 0000000000..6169706fd4
--- /dev/null
+++ b/database/migrations/2016_02_04_144117_changes_for_v380.php
@@ -0,0 +1,43 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+
+/**
+ * Class ChangesForV380
+ */
+class ChangesForV380 extends Migration
+{
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ }
+
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ // new table "rule_groups"
+ Schema::create(
+ 'export_jobs', function (Blueprint $table) {
+ $table->increments('id');
+ $table->timestamps();
+ $table->integer('user_id')->unsigned();
+ $table->string('key', 12)->unique();
+ $table->string('status', 45);
+
+ // connect rule groups to users
+ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
+
+ }
+ );
+ }
+}
diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php
index ae2df0622c..487d5a85a0 100644
--- a/database/seeds/TestDataSeeder.php
+++ b/database/seeds/TestDataSeeder.php
@@ -71,7 +71,7 @@ class TestDataSeeder extends Seeder
$this->createRevenueAccounts($user);
// create journal + attachment:
- $this->createAttachments($user);
+ TestData::createAttachments($user, $this->start);
// create opening balance for savings account:
$this->openingBalanceSavings($user);
@@ -83,83 +83,6 @@ class TestDataSeeder extends Seeder
TestData::createTags($user);
}
- /**
- * @param User $user
- */
- private function createAttachments(User $user)
- {
-
- $toAccount = TestData::findAccount($user, 'TestData Checking Account');
- $fromAccount = TestData::findAccount($user, 'Job');
-
- $journal = TransactionJournal::create(
- [
- 'user_id' => $user->id,
- 'transaction_type_id' => 2,
- 'transaction_currency_id' => 1,
- 'description' => 'Some journal for attachment',
- 'completed' => 1,
- 'date' => $this->start->format('Y-m-d'),
- ]
- );
- Transaction::create(
- [
- 'account_id' => $fromAccount->id,
- 'transaction_journal_id' => $journal->id,
- 'amount' => -100,
-
- ]
- );
- Transaction::create(
- [
- 'account_id' => $toAccount->id,
- 'transaction_journal_id' => $journal->id,
- 'amount' => 100,
-
- ]
- );
-
- // and now attachments
- $encrypted = Crypt::encrypt('I are secret');
- Attachment::create(
- [
- 'attachable_id' => $journal->id,
- 'attachable_type' => 'FireflyIII\Models\TransactionJournal',
- 'user_id' => $user->id,
- 'md5' => md5('Hallo'),
- 'filename' => 'empty-file.txt',
- 'title' => 'Empty file',
- 'description' => 'This file is empty',
- 'notes' => 'What notes',
- 'mime' => 'text/plain',
- 'size' => strlen($encrypted),
- 'uploaded' => 1,
- ]
- );
-
-
- // and now attachment.
- Attachment::create(
- [
- 'attachable_id' => $journal->id,
- 'attachable_type' => 'FireflyIII\Models\TransactionJournal',
- 'user_id' => $user->id,
- 'md5' => md5('Ook hallo'),
- 'filename' => 'empty-file-2.txt',
- 'title' => 'Empty file 2',
- 'description' => 'This file is empty too',
- 'notes' => 'What notes do',
- 'mime' => 'text/plain',
- 'size' => strlen($encrypted),
- 'uploaded' => 1,
- ]
- );
- // echo crypted data to the file.
- file_put_contents(storage_path('upload/at-1.data'), $encrypted);
- file_put_contents(storage_path('upload/at-2.data'), $encrypted);
-
- }
-
/**
* @param User $user
*/
diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php
index b158bb283b..672ff770ac 100644
--- a/database/seeds/VisualTestDataSeeder.php
+++ b/database/seeds/VisualTestDataSeeder.php
@@ -3,7 +3,6 @@ use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
-use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Category;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Preference;
@@ -457,6 +456,9 @@ class VisualTestDataSeeder extends Seeder
$start = Carbon::now()->subYears(2)->startOfMonth();
$end = Carbon::now()->endOfDay();
+ // create journal + attachment:
+ TestData::createAttachments($this->user, $start);
+
$current = clone $start;
while ($current < $end) {
@@ -487,9 +489,9 @@ class VisualTestDataSeeder extends Seeder
$this->createCar($current);
// budget limit for this month, on "Groceries".
- TestData::createBudgetLimit($current, 'Groceries', 400);
- TestData::createBudgetLimit($current, 'Bills', 1000);
- TestData::createBudgetLimit($current, 'Car', 100);
+ TestData::createBudgetLimit($this->user, $current, 'Groceries', 400);
+ TestData::createBudgetLimit($this->user, $current, 'Bills', 1000);
+ TestData::createBudgetLimit($this->user, $current, 'Car', 100);
echo 'Created test data for ' . $month . "\n";
$current->addMonth();