1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 17:31:35 +02:00
invoiceninja/database/migrations/2016_03_22_168362_add_documents.php

71 lines
2.5 KiB
PHP
Raw Normal View History

2016-03-23 03:23:45 +01:00
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
2017-01-30 17:05:31 +01:00
class AddDocuments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function ($table) {
$table->string('logo')->nullable()->default(null);
$table->unsignedInteger('logo_width');
$table->unsignedInteger('logo_height');
$table->unsignedInteger('logo_size');
$table->boolean('invoice_embed_documents')->default(0);
$table->boolean('document_email_attachment')->default(0);
});
2016-05-25 15:16:34 +02:00
2017-01-30 17:05:31 +01:00
\DB::table('accounts')->update(array('logo' => ''));
Schema::dropIfExists('documents');
Schema::create('documents', function ($t) {
2016-03-23 03:23:45 +01:00
$t->increments('id');
2017-01-30 17:05:31 +01:00
$t->unsignedInteger('public_id')->nullable();
$t->unsignedInteger('account_id');
$t->unsignedInteger('user_id');
2016-03-23 03:23:45 +01:00
$t->unsignedInteger('invoice_id')->nullable();
$t->unsignedInteger('expense_id')->nullable();
$t->string('path');
2017-01-30 17:05:31 +01:00
$t->string('preview');
$t->string('name');
$t->string('type');
$t->string('disk');
$t->string('hash', 40);
2016-03-23 03:23:45 +01:00
$t->unsignedInteger('size');
2017-01-30 17:05:31 +01:00
$t->unsignedInteger('width')->nullable();
$t->unsignedInteger('height')->nullable();
2016-03-23 03:23:45 +01:00
$t->timestamps();
2017-01-30 17:05:31 +01:00
});
2016-03-23 03:23:45 +01:00
2017-01-30 17:05:31 +01:00
Schema::table('documents', function ($t) {
2016-05-25 15:16:34 +02:00
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
2017-01-30 17:05:31 +01:00
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade');
$t->unique(array('account_id','public_id'));
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('accounts', function ($table) {
$table->dropColumn('logo');
$table->dropColumn('logo_width');
$table->dropColumn('logo_height');
$table->dropColumn('logo_size');
$table->dropColumn('invoice_embed_documents');
$table->dropColumn('document_email_attachment');
2016-05-25 15:16:34 +02:00
});
2017-01-30 17:05:31 +01:00
Schema::dropIfExists('documents');
}
2016-03-23 03:23:45 +01:00
}