2016-03-22 22:23:45 -04:00
|
|
|
<?php
|
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
|
|
class AddDocuments extends Migration {
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function up()
|
|
|
|
|
{
|
2016-03-23 18:40:42 -04:00
|
|
|
Schema::table('accounts', function($table) {
|
2016-03-22 22:23:45 -04:00
|
|
|
$table->string('logo')->nullable()->default(null);
|
|
|
|
|
$table->unsignedInteger('logo_width');
|
|
|
|
|
$table->unsignedInteger('logo_height');
|
|
|
|
|
$table->unsignedInteger('logo_size');
|
2016-03-23 18:40:42 -04:00
|
|
|
$table->boolean('invoice_embed_documents')->default(1);
|
2016-03-23 19:20:08 -04:00
|
|
|
$table->boolean('document_email_attachment')->default(1);
|
2016-03-22 22:23:45 -04:00
|
|
|
});
|
2016-05-25 16:16:56 +03:00
|
|
|
|
2016-05-12 12:46:04 +03:00
|
|
|
\DB::table('accounts')->update(array('logo' => ''));
|
2016-03-22 22:23:45 -04:00
|
|
|
Schema::dropIfExists('documents');
|
|
|
|
|
Schema::create('documents', function($t)
|
|
|
|
|
{
|
|
|
|
|
$t->increments('id');
|
|
|
|
|
$t->unsignedInteger('public_id')->nullable();
|
|
|
|
|
$t->unsignedInteger('account_id');
|
|
|
|
|
$t->unsignedInteger('user_id');
|
|
|
|
|
$t->unsignedInteger('invoice_id')->nullable();
|
|
|
|
|
$t->unsignedInteger('expense_id')->nullable();
|
|
|
|
|
$t->string('path');
|
2016-03-23 15:41:05 -04:00
|
|
|
$t->string('preview');
|
2016-03-22 22:23:45 -04:00
|
|
|
$t->string('name');
|
|
|
|
|
$t->string('type');
|
|
|
|
|
$t->string('disk');
|
2016-03-23 22:41:19 -04:00
|
|
|
$t->string('hash', 40);
|
2016-03-22 22:23:45 -04:00
|
|
|
$t->unsignedInteger('size');
|
|
|
|
|
$t->unsignedInteger('width')->nullable();
|
|
|
|
|
$t->unsignedInteger('height')->nullable();
|
|
|
|
|
|
|
|
|
|
$t->timestamps();
|
|
|
|
|
|
2016-05-25 16:16:56 +03:00
|
|
|
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
|
|
|
|
$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');
|
2016-03-22 22:23:45 -04:00
|
|
|
|
2016-05-25 16:16:56 +03:00
|
|
|
|
2016-03-22 22:23:45 -04:00
|
|
|
$t->unique( array('account_id','public_id') );
|
2016-05-25 16:16:56 +03:00
|
|
|
});
|
2016-03-22 22:23:45 -04:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 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');
|
2016-03-23 18:40:42 -04:00
|
|
|
$table->dropColumn('invoice_embed_documents');
|
2016-04-16 20:15:02 -04:00
|
|
|
$table->dropColumn('document_email_attachment');
|
2016-03-22 22:23:45 -04:00
|
|
|
});
|
2016-05-25 16:16:56 +03:00
|
|
|
|
2016-03-22 22:23:45 -04:00
|
|
|
Schema::dropIfExists('documents');
|
|
|
|
|
}
|
|
|
|
|
}
|