first commit

This commit is contained in:
denisdulici
2017-09-14 22:21:00 +03:00
commit 515bdaf5cd
598 changed files with 48030 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accounts', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('number');
$table->string('currency_code');
$table->decimal('opening_balance')->default('0');
$table->string('bank_name')->nullable();
$table->string('bank_phone')->nullable();
$table->text('bank_address')->nullable();
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('accounts');
}
}

View File

@ -0,0 +1,116 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateBillsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bills', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('bill_number');
$table->string('order_number')->nullable();
$table->string('bill_status_code');
$table->date('billed_at');
$table->date('due_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->integer('vendor_id');
$table->string('vendor_name');
$table->string('vendor_email');
$table->string('vendor_tax_number')->nullable();
$table->string('vendor_phone')->nullable();
$table->text('vendor_address')->nullable();
$table->text('notes')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'bill_number', 'deleted_at']);
});
Schema::create('bill_items', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('bill_id');
$table->integer('item_id')->nullable();
$table->string('name');
$table->string('sku')->nullable();
$table->integer('quantity');
$table->float('price', 15, 4);
$table->float('total', 15, 4);
$table->float('tax', 15, 4)->default('0.0000');
$table->integer('tax_id');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('bill_statuses', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('code');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('bill_payments', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('bill_id');
$table->integer('account_id');
$table->date('paid_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->text('description')->nullable();
$table->string('payment_method');
$table->string('reference')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('bill_histories', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('bill_id');
$table->string('status_code');
$table->boolean('notify');
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('bills');
Schema::drop('bill_items');
Schema::drop('bill_statuses');
Schema::drop('bill_payments');
Schema::drop('bill_histories');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('type');
$table->string('color');
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('categories');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCompaniesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->string('domain');
$table->boolean('enabled')->default(0);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('companies');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCurrenciesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('currencies', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('code');
$table->float('rate', 15, 8);
$table->tinyInteger('enabled')->default(0);
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'code', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('currencies');
}
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCustomersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('user_id')->nullable();
$table->string('name');
$table->string('email');
$table->string('tax_number')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->string('website')->nullable();
$table->string('currency_code');
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'email', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('customers');
}
}

View File

@ -0,0 +1,116 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateInvoicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('invoice_number');
$table->string('order_number')->nullable();
$table->string('invoice_status_code');
$table->date('invoiced_at');
$table->date('due_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->integer('customer_id');
$table->string('customer_name');
$table->string('customer_email');
$table->string('customer_tax_number')->nullable();
$table->string('customer_phone')->nullable();
$table->text('customer_address')->nullable();
$table->text('notes')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'invoice_number', 'deleted_at']);
});
Schema::create('invoice_items', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('invoice_id');
$table->integer('item_id')->nullable();
$table->string('name');
$table->string('sku')->nullable();
$table->integer('quantity');
$table->float('price', 15, 4);
$table->float('total', 15, 4);
$table->float('tax', 15, 4)->default('0.0000');
$table->integer('tax_id');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('invoice_statuses', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('code');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('invoice_payments', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('invoice_id');
$table->integer('account_id');
$table->date('paid_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->text('description')->nullable();
$table->string('payment_method');
$table->string('reference')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
Schema::create('invoice_histories', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('invoice_id');
$table->string('status_code');
$table->boolean('notify');
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoices');
Schema::drop('invoice_items');
Schema::drop('invoice_statuses');
Schema::drop('invoice_payments');
Schema::drop('invoice_histories');
}
}

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('items', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('sku');
$table->text('description')->nullable();
$table->float('sale_price', 15, 4);
$table->float('purchase_price', 15, 4);
$table->integer('quantity');
$table->integer('category_id')->nullable();
$table->integer('tax_id')->nullable();
$table->string('picture')->nullable();
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'sku', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('items');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}

View File

@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateModulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('alias');
$table->integer('status');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'alias', 'deleted_at']);
});
Schema::create('module_histories', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('module_id');
$table->string('category');
$table->string('version');
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['company_id', 'module_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('modules');
Schema::drop('module_histories');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email');
$table->string('token');
$table->timestamp('created_at')->nullable();
$table->index('email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePaymentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payments', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('account_id');
$table->date('paid_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->integer('vendor_id')->nullable();
$table->text('description')->nullable();
$table->integer('category_id');
$table->string('payment_method');
$table->string('reference')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('payments');
}
}

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateRevenuesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('revenues', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('account_id');
$table->date('paid_at');
$table->float('amount', 15, 4);
$table->string('currency_code');
$table->float('currency_rate', 15, 8);
$table->integer('customer_id')->nullable();
$table->text('description')->nullable();
$table->integer('category_id');
$table->string('payment_method');
$table->string('reference')->nullable();
$table->string('attachment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('revenues');
}
}

View File

@ -0,0 +1,89 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Create table for storing roles
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('display_name');
$table->string('description')->nullable();
$table->timestamps();
$table->unique('name');
});
// Create table for associating roles to users (Many To Many Polymorphic)
Schema::create('user_roles', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->string('user_type');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'role_id', 'user_type']);
});
// Create table for storing permissions
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('display_name');
$table->string('description')->nullable();
$table->timestamps();
$table->unique('name');
});
// Create table for associating permissions to roles (Many-to-Many)
Schema::create('role_permissions', function (Blueprint $table) {
$table->integer('role_id')->unsigned();
$table->integer('permission_id')->unsigned();
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['role_id', 'permission_id']);
});
// Create table for associating permissions to users (Many To Many Polymorphic)
Schema::create('user_permissions', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('permission_id')->unsigned();
$table->string('user_type');
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'permission_id', 'user_type']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Cascade table first
Schema::dropIfExists('user_permissions');
Schema::dropIfExists('role_permissions');
Schema::dropIfExists('permissions');
Schema::dropIfExists('user_roles');
Schema::dropIfExists('roles');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSessionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->unsignedInteger('user_id')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sessions');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('key');
$table->text('value')->nullable();
$table->index('company_id');
$table->unique(['company_id', 'key']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('settings');
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTaxesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('taxes', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->integer('rate');
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('taxes');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTransfersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transfers', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('payment_id');
$table->integer('revenue_id');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transfers');
}
}

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->string('password');
$table->rememberToken();
$table->string('picture')->nullable();
$table->timestamp('last_logged_in_at')->nullable();
$table->boolean('enabled')->default(1);
$table->timestamps();
$table->softDeletes();
$table->unique(['email', 'deleted_at']);
});
// Create table for associating companies to users (Many To Many Polymorphic)
Schema::create('user_companies', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('company_id')->unsigned();
$table->string('user_type');
$table->primary(['user_id', 'company_id', 'user_type']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Cascade table first
Schema::dropIfExists('user_companies');
Schema::dropIfExists('users');
}
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateVendorsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('vendors', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('user_id')->nullable();
$table->string('name');
$table->string('email');
$table->string('tax_number')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->string('website')->nullable();
$table->string('currency_code');
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'email', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('vendors');
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddLocaleColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function ($table) {
$table->string('locale')->default(config('app.locale'));
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function ($table) {
$table->dropColumn('locale');
});
}
}