mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
New migrations (also for export).
This commit is contained in:
43
database/migrations/2016_02_04_144117_changes_for_v380.php
Normal file
43
database/migrations/2016_02_04_144117_changes_for_v380.php
Normal 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');
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -71,7 +71,7 @@ class TestDataSeeder extends Seeder
|
|||||||
$this->createRevenueAccounts($user);
|
$this->createRevenueAccounts($user);
|
||||||
|
|
||||||
// create journal + attachment:
|
// create journal + attachment:
|
||||||
$this->createAttachments($user);
|
TestData::createAttachments($user, $this->start);
|
||||||
|
|
||||||
// create opening balance for savings account:
|
// create opening balance for savings account:
|
||||||
$this->openingBalanceSavings($user);
|
$this->openingBalanceSavings($user);
|
||||||
@@ -83,83 +83,6 @@ class TestDataSeeder extends Seeder
|
|||||||
TestData::createTags($user);
|
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
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
|
@@ -3,7 +3,6 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
@@ -457,6 +456,9 @@ class VisualTestDataSeeder extends Seeder
|
|||||||
$start = Carbon::now()->subYears(2)->startOfMonth();
|
$start = Carbon::now()->subYears(2)->startOfMonth();
|
||||||
$end = Carbon::now()->endOfDay();
|
$end = Carbon::now()->endOfDay();
|
||||||
|
|
||||||
|
// create journal + attachment:
|
||||||
|
TestData::createAttachments($this->user, $start);
|
||||||
|
|
||||||
|
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
while ($current < $end) {
|
while ($current < $end) {
|
||||||
@@ -487,9 +489,9 @@ class VisualTestDataSeeder extends Seeder
|
|||||||
$this->createCar($current);
|
$this->createCar($current);
|
||||||
|
|
||||||
// budget limit for this month, on "Groceries".
|
// budget limit for this month, on "Groceries".
|
||||||
TestData::createBudgetLimit($current, 'Groceries', 400);
|
TestData::createBudgetLimit($this->user, $current, 'Groceries', 400);
|
||||||
TestData::createBudgetLimit($current, 'Bills', 1000);
|
TestData::createBudgetLimit($this->user, $current, 'Bills', 1000);
|
||||||
TestData::createBudgetLimit($current, 'Car', 100);
|
TestData::createBudgetLimit($this->user, $current, 'Car', 100);
|
||||||
|
|
||||||
echo 'Created test data for ' . $month . "\n";
|
echo 'Created test data for ' . $month . "\n";
|
||||||
$current->addMonth();
|
$current->addMonth();
|
||||||
|
Reference in New Issue
Block a user