New migrations (also for export).

This commit is contained in:
James Cole 2016-02-04 17:13:58 +01:00
parent 78f8b1454d
commit 3bb107e192
3 changed files with 50 additions and 82 deletions

View File

@ -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');
}
);
}
}

View File

@ -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
*/

View File

@ -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();