diff --git a/app/Listeners/Update/V20/Version200.php b/app/Listeners/Update/V20/Version200.php index bcfaef30e..241405858 100644 --- a/app/Listeners/Update/V20/Version200.php +++ b/app/Listeners/Update/V20/Version200.php @@ -39,8 +39,7 @@ class Version200 extends Listener // Cache Clear Artisan::call('cache:clear'); - // Update database - Artisan::call('migrate', ['--force' => true]); + $this->updateDatabase(); $this->updateCompanies(); @@ -61,6 +60,17 @@ class Version200 extends Listener $this->deleteOldFiles(); } + public function updateDatabase() + { + DB::table('migrations')->insert([ + 'id' => DB::table('migrations')->max('id') + 1, + 'migration' => '2017_09_14_000000_core_v1', + 'batch' => DB::table('migrations')->max('batch') + 1, + ]); + + Artisan::call('migrate', ['--force' => true]); + } + protected function updateCompanies() { $company_id = session('company_id'); diff --git a/database/migrations/2017_09_01_000000_create_accounts_table.php b/database/migrations/2017_09_01_000000_create_accounts_table.php deleted file mode 100644 index e69227598..000000000 --- a/database/migrations/2017_09_01_000000_create_accounts_table.php +++ /dev/null @@ -1,43 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('name'); - $table->string('number'); - $table->string('currency_code'); - $table->double('opening_balance', 15, 4)->default('0.0000'); - $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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_bills_table.php b/database/migrations/2017_09_01_000000_create_bills_table.php deleted file mode 100644 index 6947f7754..000000000 --- a/database/migrations/2017_09_01_000000_create_bills_table.php +++ /dev/null @@ -1,117 +0,0 @@ -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->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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->double('quantity', 7, 2); - $table->double('price', 15, 4); - $table->double('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->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_categories_table.php b/database/migrations/2017_09_01_000000_create_categories_table.php deleted file mode 100644 index a548417c3..000000000 --- a/database/migrations/2017_09_01_000000_create_categories_table.php +++ /dev/null @@ -1,39 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_companies_table.php b/database/migrations/2017_09_01_000000_create_companies_table.php deleted file mode 100644 index 23847b18a..000000000 --- a/database/migrations/2017_09_01_000000_create_companies_table.php +++ /dev/null @@ -1,34 +0,0 @@ -increments('id'); - $table->string('domain')->nullable(); - $table->boolean('enabled')->default(1); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('companies'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_currencies_table.php b/database/migrations/2017_09_01_000000_create_currencies_table.php deleted file mode 100644 index 33584837a..000000000 --- a/database/migrations/2017_09_01_000000_create_currencies_table.php +++ /dev/null @@ -1,40 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('name'); - $table->string('code'); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_customers_table.php b/database/migrations/2017_09_01_000000_create_customers_table.php deleted file mode 100644 index d0840d783..000000000 --- a/database/migrations/2017_09_01_000000_create_customers_table.php +++ /dev/null @@ -1,45 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_invoices_table.php b/database/migrations/2017_09_01_000000_create_invoices_table.php deleted file mode 100644 index 4ad4ec570..000000000 --- a/database/migrations/2017_09_01_000000_create_invoices_table.php +++ /dev/null @@ -1,117 +0,0 @@ -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->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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->double('quantity', 7, 2); - $table->double('price', 15, 4); - $table->double('total', 15, 4); - $table->double('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->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_items_table.php b/database/migrations/2017_09_01_000000_create_items_table.php deleted file mode 100644 index 2ad69782e..000000000 --- a/database/migrations/2017_09_01_000000_create_items_table.php +++ /dev/null @@ -1,46 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('name'); - $table->string('sku'); - $table->text('description')->nullable(); - $table->double('sale_price', 15, 4); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_jobs_table.php b/database/migrations/2017_09_01_000000_create_jobs_table.php deleted file mode 100644 index bbd1f7f7c..000000000 --- a/database/migrations/2017_09_01_000000_create_jobs_table.php +++ /dev/null @@ -1,38 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_modules_table.php b/database/migrations/2017_09_01_000000_create_modules_table.php deleted file mode 100644 index 8cc5d98af..000000000 --- a/database/migrations/2017_09_01_000000_create_modules_table.php +++ /dev/null @@ -1,52 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_notifications_table.php b/database/migrations/2017_09_01_000000_create_notifications_table.php deleted file mode 100644 index 9797596dc..000000000 --- a/database/migrations/2017_09_01_000000_create_notifications_table.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_password_resets_table.php b/database/migrations/2017_09_01_000000_create_password_resets_table.php deleted file mode 100644 index 725b68783..000000000 --- a/database/migrations/2017_09_01_000000_create_password_resets_table.php +++ /dev/null @@ -1,34 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_payments_table.php b/database/migrations/2017_09_01_000000_create_payments_table.php deleted file mode 100644 index 26fbadcc9..000000000 --- a/database/migrations/2017_09_01_000000_create_payments_table.php +++ /dev/null @@ -1,46 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('account_id'); - $table->date('paid_at'); - $table->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_revenues_table.php b/database/migrations/2017_09_01_000000_create_revenues_table.php deleted file mode 100644 index 0780fc27f..000000000 --- a/database/migrations/2017_09_01_000000_create_revenues_table.php +++ /dev/null @@ -1,46 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('account_id'); - $table->date('paid_at'); - $table->double('amount', 15, 4); - $table->string('currency_code'); - $table->double('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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_roles_table.php b/database/migrations/2017_09_01_000000_create_roles_table.php deleted file mode 100644 index bbb77201d..000000000 --- a/database/migrations/2017_09_01_000000_create_roles_table.php +++ /dev/null @@ -1,91 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_sessions_table.php b/database/migrations/2017_09_01_000000_create_sessions_table.php deleted file mode 100644 index 01dcba543..000000000 --- a/database/migrations/2017_09_01_000000_create_sessions_table.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_settings_table.php b/database/migrations/2017_09_01_000000_create_settings_table.php deleted file mode 100644 index e8f92ac40..000000000 --- a/database/migrations/2017_09_01_000000_create_settings_table.php +++ /dev/null @@ -1,36 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_taxes_table.php b/database/migrations/2017_09_01_000000_create_taxes_table.php deleted file mode 100644 index 6c74e8c56..000000000 --- a/database/migrations/2017_09_01_000000_create_taxes_table.php +++ /dev/null @@ -1,38 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('name'); - $table->double('rate', 15, 4); - $table->boolean('enabled'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('taxes'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_transfers_table.php b/database/migrations/2017_09_01_000000_create_transfers_table.php deleted file mode 100644 index 4b98d6fce..000000000 --- a/database/migrations/2017_09_01_000000_create_transfers_table.php +++ /dev/null @@ -1,37 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_users_table.php b/database/migrations/2017_09_01_000000_create_users_table.php deleted file mode 100644 index 6bb98822c..000000000 --- a/database/migrations/2017_09_01_000000_create_users_table.php +++ /dev/null @@ -1,52 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_01_000000_create_vendors_table.php b/database/migrations/2017_09_01_000000_create_vendors_table.php deleted file mode 100644 index 53d4bd96e..000000000 --- a/database/migrations/2017_09_01_000000_create_vendors_table.php +++ /dev/null @@ -1,45 +0,0 @@ -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'); - } -} diff --git a/database/migrations/2017_09_14_000000_core_v1.php b/database/migrations/2017_09_14_000000_core_v1.php new file mode 100644 index 000000000..b543d524c --- /dev/null +++ b/database/migrations/2017_09_14_000000_core_v1.php @@ -0,0 +1,596 @@ +increments('id'); + $table->integer('company_id'); + $table->string('name'); + $table->string('number'); + $table->string('currency_code'); + $table->double('opening_balance', 15, 4)->default('0.0000'); + $table->string('bank_name')->nullable(); + $table->string('bank_phone')->nullable(); + $table->text('bank_address')->nullable(); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Bills + 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->dateTime('billed_at'); + $table->dateTime('due_at'); + $table->double('amount', 15, 4); + $table->string('currency_code'); + $table->double('currency_rate', 15, 8); + $table->integer('category_id')->default(1); + $table->integer('vendor_id'); + $table->string('vendor_name'); + $table->string('vendor_email')->nullable(); + $table->string('vendor_tax_number')->nullable(); + $table->string('vendor_phone')->nullable(); + $table->text('vendor_address')->nullable(); + $table->text('notes')->nullable(); + $table->integer('parent_id')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + $table->unique(['company_id', 'bill_number', 'deleted_at']); + }); + + 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'); + }); + + 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->double('quantity', 7, 2); + $table->double('price', 15, 4); + $table->double('total', 15, 4); + $table->float('tax', 15, 4)->default('0.0000'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + Schema::create('bill_item_taxes', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('bill_id'); + $table->integer('bill_item_id'); + $table->integer('tax_id'); + $table->string('name'); + $table->double('amount', 15, 4)->default('0.0000'); + $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_totals', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('bill_id'); + $table->string('code')->nullable(); + $table->string('name'); + $table->double('amount', 15, 4); + $table->integer('sort_order'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Categories + 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')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Companies + Schema::create('companies', function (Blueprint $table) { + $table->increments('id'); + $table->string('domain'); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + }); + + // Currencies + Schema::create('currencies', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('name'); + $table->string('code'); + $table->double('rate', 15, 8); + $table->string('precision')->nullable(); + $table->string('symbol')->nullable(); + $table->integer('symbol_first')->default(1); + $table->string('decimal_mark')->nullable(); + $table->string('thousands_separator')->nullable(); + $table->tinyInteger('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + $table->unique(['company_id', 'code', 'deleted_at']); + }); + + // Invoices + 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->dateTime('invoiced_at'); + $table->dateTime('due_at'); + $table->double('amount', 15, 4); + $table->string('currency_code'); + $table->double('currency_rate', 15, 8); + $table->integer('category_id')->default(1); + $table->integer('customer_id'); + $table->string('customer_name'); + $table->string('customer_email')->nullable(); + $table->string('customer_tax_number')->nullable(); + $table->string('customer_phone')->nullable(); + $table->text('customer_address')->nullable(); + $table->text('notes')->nullable(); + $table->integer('parent_id')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + $table->unique(['company_id', 'invoice_number', 'deleted_at']); + }); + + 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'); + }); + + 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->double('quantity', 7, 2); + $table->double('price', 15, 4); + $table->double('total', 15, 4); + $table->double('tax', 15, 4)->default('0.0000'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + Schema::create('invoice_item_taxes', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('invoice_id'); + $table->integer('invoice_item_id'); + $table->integer('tax_id'); + $table->string('name'); + $table->double('amount', 15, 4)->default('0.0000'); + $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_totals', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('invoice_id'); + $table->string('code')->nullable(); + $table->string('name'); + $table->double('amount', 15, 4); + $table->integer('sort_order'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Items + Schema::create('items', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('name'); + $table->string('sku'); + $table->text('description')->nullable(); + $table->double('sale_price', 15, 4); + $table->double('purchase_price', 15, 4); + $table->integer('quantity'); + $table->integer('category_id')->nullable(); + $table->integer('tax_id')->nullable(); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + $table->unique(['company_id', 'sku', 'deleted_at']); + }); + + // Jobs + 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']); + }); + + Schema::create('failed_jobs', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + + // Media + Schema::create('media', function (Blueprint $table) { + $table->increments('id'); + $table->string('disk', 32); + $table->string('directory', 68); + $table->string('filename', 121); + $table->string('extension', 28); + $table->string('mime_type', 128); + $table->string('aggregate_type', 32); + $table->integer('size')->unsigned(); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['disk', 'directory']); + $table->index('aggregate_type'); + $table->unique(['disk', 'directory', 'filename', 'extension', 'deleted_at']); + }); + + Schema::create('mediables', function (Blueprint $table) { + $table->integer('media_id')->unsigned(); + $table->string('mediable_type', 152); + $table->integer('mediable_id')->unsigned(); + $table->string('tag', 68); + $table->integer('order')->unsigned(); + + $table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']); + $table->index(['mediable_id', 'mediable_type']); + $table->index('tag'); + $table->index('order'); + $table->foreign('media_id')->references('id')->on('media')->onDelete('cascade'); + }); + + // Modules + 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']); + }); + + // Notifications + 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(); + }); + + // Password resets + Schema::create('password_resets', function (Blueprint $table) { + $table->string('email'); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + + $table->index('email'); + }); + + // 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'); + }); + + 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'); + }); + + 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']); + }); + + 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']); + }); + + 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']); + }); + + // Reconciliations + Schema::create('reconciliations', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('account_id'); + $table->dateTime('started_at'); + $table->dateTime('ended_at'); + $table->double('closing_balance', 15, 4)->default('0.0000'); + $table->boolean('reconciled'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Recurring + Schema::create('recurring', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->morphs('recurable'); + $table->string('frequency'); + $table->integer('interval')->default(1); + $table->dateTime('started_at'); + $table->integer('count')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Sessions + 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'); + }); + + // Settings + 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']); + }); + + // Taxes + Schema::create('taxes', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('name'); + $table->double('rate', 15, 4); + $table->string('type')->default('normal'); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Transfers + 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'); + }); + + // Users + Schema::create('users', function (Blueprint $table) { + $table->increments('id'); + $table->string('name'); + $table->string('email'); + $table->string('password'); + $table->rememberToken(); + $table->timestamp('last_logged_in_at')->nullable(); + $table->string('locale')->default(config('app.locale')); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->unique(['email', 'deleted_at']); + }); + + 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() + { + Schema::drop('accounts'); + Schema::drop('bills'); + Schema::drop('bill_histories'); + Schema::drop('bill_items'); + Schema::drop('bill_item_taxes'); + Schema::drop('bill_statuses'); + Schema::drop('bill_totals'); + Schema::drop('categories'); + Schema::drop('companies'); + Schema::drop('currencies'); + Schema::drop('invoices'); + Schema::drop('invoice_histories'); + Schema::drop('invoice_items'); + Schema::drop('invoice_item_taxes'); + Schema::drop('invoice_statuses'); + Schema::drop('invoice_totals'); + Schema::drop('items'); + Schema::drop('jobs'); + Schema::drop('failed_jobs'); + Schema::drop('media'); + Schema::drop('mediables'); + Schema::drop('modules'); + Schema::drop('module_histories'); + Schema::drop('notifications'); + Schema::drop('password_resets'); + + // Cascade table first + Schema::drop('user_permissions'); + Schema::drop('role_permissions'); + Schema::drop('permissions'); + Schema::drop('user_roles'); + Schema::drop('roles'); + + Schema::drop('reconciliations'); + Schema::drop('recurring'); + Schema::drop('sessions'); + Schema::drop('settings'); + Schema::drop('taxes'); + Schema::drop('transfers'); + Schema::drop('users'); + Schema::drop('user_companies'); + } +} diff --git a/database/migrations/2017_10_11_000000_create_bill_totals_table.php b/database/migrations/2017_10_11_000000_create_bill_totals_table.php deleted file mode 100644 index 31e8fc9d7..000000000 --- a/database/migrations/2017_10_11_000000_create_bill_totals_table.php +++ /dev/null @@ -1,141 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('bill_id'); - $table->string('code')->nullable(); - $table->string('name'); - $table->double('amount', 15, 4); - $table->integer('sort_order'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - - Model::unguard(); - - $companies = Company::all(); - - foreach ($companies as $company) { - $bills = Bill::where('company_id', $company->id)->get(); - - foreach ($bills as $bill) { - $bill_items = BillItem::where('company_id', $company->id)->where('bill_id', $bill->id)->get(); - - $taxes = []; - $tax_total = 0; - $sub_total = 0; - - foreach ($bill_items as $bill_item) { - unset($tax_object); - - $bill_item->total = $bill_item->price * $bill_item->quantity; - - if (!empty($bill_item->tax_id)) { - $tax_object = Tax::where('company_id', $company->id)->where('id', $bill_item->tax_id)->first(); - - $bill_item->tax = (($bill_item->price * $bill_item->quantity) / 100) * $tax_object->rate; - } - - $bill_item->update(); - - if (isset($tax_object)) { - if (array_key_exists($bill_item->tax_id, $taxes)) { - $taxes[$bill_item->tax_id]['amount'] += $bill_item->tax; - } else { - $taxes[$bill_item->tax_id] = [ - 'name' => $tax_object->name, - 'amount' => $bill_item->tax - ]; - } - } - - $tax_total += $bill_item->tax; - $sub_total += $bill_item->price * $bill_item->quantity; - } - - $bill->amount = $sub_total + $tax_total; - - $bill->update(); - - // Added bill total sub total - $bill_sub_total = [ - 'company_id' => $company->id, - 'bill_id' => $bill->id, - 'code' => 'sub_total', - 'name' => 'bills.sub_total', - 'amount' => $sub_total, - 'sort_order' => 1, - ]; - - BillTotal::create($bill_sub_total); - - $sort_order = 2; - - // Added bill total taxes - if ($taxes) { - foreach ($taxes as $tax) { - $bill_tax_total = [ - 'company_id' => $company->id, - 'bill_id' => $bill->id, - 'code' => 'tax', - 'name' => $tax['name'], - 'amount' => $tax['amount'], - 'sort_order' => $sort_order, - ]; - - BillTotal::create($bill_tax_total); - - $sort_order++; - } - } - - // Added bill total total - $bill_total = [ - 'company_id' => $company->id, - 'bill_id' => $bill->id, - 'code' => 'total', - 'name' => 'bills.total', - 'amount' => $sub_total + $tax_total, - 'sort_order' => $sort_order, - ]; - - BillTotal::create($bill_total); - } - } - - Model::reguard(); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('bill_totals'); - } -} diff --git a/database/migrations/2017_10_11_000000_create_invoice_totals_table.php b/database/migrations/2017_10_11_000000_create_invoice_totals_table.php deleted file mode 100644 index e023f31a6..000000000 --- a/database/migrations/2017_10_11_000000_create_invoice_totals_table.php +++ /dev/null @@ -1,140 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('invoice_id'); - $table->string('code')->nullable(); - $table->string('name'); - $table->double('amount', 15, 4); - $table->integer('sort_order'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - - Model::unguard(); - - $companies = Company::all(); - - foreach ($companies as $company) { - $invoices = Invoice::where('company_id', $company->id)->get(); - - foreach ($invoices as $invoice) { - $invoice_items = InvoiceItem::where('company_id', $company->id)->where('invoice_id', $invoice->id)->get(); - - $taxes = []; - $tax_total = 0; - $sub_total = 0; - - foreach ($invoice_items as $invoice_item) { - unset($tax_object); - - $invoice_item->total = $invoice_item->price * $invoice_item->quantity; - - if (!empty($invoice_item->tax_id)) { - $tax_object = Tax::where('company_id', $company->id)->where('id', $invoice_item->tax_id)->first(); - - $invoice_item->tax = (($invoice_item->price * $invoice_item->quantity) / 100) * $tax_object->rate; - } - - $invoice_item->update(); - - if (isset($tax_object)) { - if (array_key_exists($invoice_item->tax_id, $taxes)) { - $taxes[$invoice_item->tax_id]['amount'] += $invoice_item->tax; - } else { - $taxes[$invoice_item->tax_id] = [ - 'name' => $tax_object->name, - 'amount' => $invoice_item->tax - ]; - } - } - - $tax_total += $invoice_item->tax; - $sub_total += $invoice_item->price * $invoice_item->quantity; - } - - $invoice->amount = $sub_total + $tax_total; - - $invoice->update(); - - // Added invoice total sub total - $invoice_sub_total = [ - 'company_id' => $company->id, - 'invoice_id' => $invoice->id, - 'code' => 'sub_total', - 'name' => 'invoices.sub_total', - 'amount' => $sub_total, - 'sort_order' => 1, - ]; - - InvoiceTotal::create($invoice_sub_total); - - $sort_order = 2; - - // Added invoice total taxes - if ($taxes) { - foreach ($taxes as $tax) { - $invoice_tax_total = [ - 'company_id' => $company->id, - 'invoice_id' => $invoice->id, - 'code' => 'tax', - 'name' => $tax['name'], - 'amount' => $tax['amount'], - 'sort_order' => $sort_order, - ]; - - InvoiceTotal::create($invoice_tax_total); - - $sort_order++; - } - } - - // Added invoice total total - $invoice_total = [ - 'company_id' => $company->id, - 'invoice_id' => $invoice->id, - 'code' => 'total', - 'name' => 'invoices.total', - 'amount' => $sub_total + $tax_total, - 'sort_order' => $sort_order, - ]; - - InvoiceTotal::create($invoice_total); - } - } - - Model::reguard(); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('invoice_totals'); - } -} diff --git a/database/migrations/2017_11_16_000000_create_failed_jobs_table.php b/database/migrations/2017_11_16_000000_create_failed_jobs_table.php deleted file mode 100644 index 389bdf768..000000000 --- a/database/migrations/2017_11_16_000000_create_failed_jobs_table.php +++ /dev/null @@ -1,35 +0,0 @@ -bigIncrements('id'); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('failed_jobs'); - } -} diff --git a/database/migrations/2017_12_09_000000_add_currency_columns.php b/database/migrations/2017_12_09_000000_add_currency_columns.php deleted file mode 100644 index 8f663eb0f..000000000 --- a/database/migrations/2017_12_09_000000_add_currency_columns.php +++ /dev/null @@ -1,42 +0,0 @@ -string('precision')->nullable(); - $table->string('symbol')->nullable(); - $table->integer('symbol_first')->default(1); - $table->string('decimal_mark')->nullable(); - $table->string('thousands_separator')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('currencies', function (Blueprint $table) { - $table->dropColumn([ - 'precision', - 'symbol', - 'symbol_first', - 'decimal_mark', - 'thousands_separator', - ]); - }); - } -} diff --git a/database/migrations/2017_12_30_000000_create_mediable_tables.php b/database/migrations/2017_12_30_000000_create_mediable_tables.php deleted file mode 100644 index b297bb751..000000000 --- a/database/migrations/2017_12_30_000000_create_mediable_tables.php +++ /dev/null @@ -1,58 +0,0 @@ -increments('id'); - $table->string('disk', 32); - $table->string('directory', 68); - $table->string('filename', 121); - $table->string('extension', 28); - $table->string('mime_type', 128); - $table->string('aggregate_type', 32); - $table->integer('size')->unsigned(); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['disk', 'directory']); - $table->unique(['disk', 'directory', 'filename', 'extension']); - $table->index('aggregate_type'); - }); - - Schema::create('mediables', function (Blueprint $table) { - $table->integer('media_id')->unsigned(); - $table->string('mediable_type', 152); - $table->integer('mediable_id')->unsigned(); - $table->string('tag', 68); - $table->integer('order')->unsigned(); - - $table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']); - $table->index(['mediable_id', 'mediable_type']); - $table->index('tag'); - $table->index('order'); - $table->foreign('media_id')->references('id')->on('media')->onDelete('cascade'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('mediables'); - Schema::drop('media'); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_bill_payments_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_bill_payments_table.php deleted file mode 100644 index 171dc92fe..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_bill_payments_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('bill_payments', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_bills_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_bills_table.php deleted file mode 100644 index 6aea59ccc..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_bills_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('bills', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_invoice_payments_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_invoice_payments_table.php deleted file mode 100644 index 0b4f4337f..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_invoice_payments_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoice_payments', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_invoices_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_invoices_table.php deleted file mode 100644 index 29262e56f..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_invoices_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_payments_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_payments_table.php deleted file mode 100644 index 2674ec4a0..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_payments_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('payments', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_attachment_column_revenues_table.php b/database/migrations/2018_01_03_000000_drop_attachment_column_revenues_table.php deleted file mode 100644 index 27059c311..000000000 --- a/database/migrations/2018_01_03_000000_drop_attachment_column_revenues_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('attachment'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('revenues', function (Blueprint $table) { - $table->string('attachment')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_picture_column_items_table.php b/database/migrations/2018_01_03_000000_drop_picture_column_items_table.php deleted file mode 100644 index 32bc587c5..000000000 --- a/database/migrations/2018_01_03_000000_drop_picture_column_items_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('picture'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('items', function (Blueprint $table) { - $table->string('picture')->nullable(); - }); - } -} diff --git a/database/migrations/2018_01_03_000000_drop_picture_column_users_table.php b/database/migrations/2018_01_03_000000_drop_picture_column_users_table.php deleted file mode 100644 index a6c9f4f78..000000000 --- a/database/migrations/2018_01_03_000000_drop_picture_column_users_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropColumn('picture'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function (Blueprint $table) { - $table->string('picture')->nullable(); - }); - } -} diff --git a/database/migrations/2018_04_23_000000_add_category_column_invoices_bills.php b/database/migrations/2018_04_23_000000_add_category_column_invoices_bills.php deleted file mode 100644 index 9b6361760..000000000 --- a/database/migrations/2018_04_23_000000_add_category_column_invoices_bills.php +++ /dev/null @@ -1,40 +0,0 @@ -integer('category_id')->default(); - }); - - Schema::table('bills', function (Blueprint $table) { - $table->integer('category_id')->default(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function (Blueprint $table) { - $table->dropColumn('category_id'); - }); - - Schema::table('bills', function (Blueprint $table) { - $table->dropColumn('category_id'); - }); - } -} diff --git a/database/migrations/2018_04_26_000000_create_recurring_table.php b/database/migrations/2018_04_26_000000_create_recurring_table.php deleted file mode 100644 index 4c87cda84..000000000 --- a/database/migrations/2018_04_26_000000_create_recurring_table.php +++ /dev/null @@ -1,38 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->morphs('recurable'); - $table->string('frequency'); - $table->integer('interval')->default(1); - $table->date('started_at'); - $table->integer('count')->default(0); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('recurring'); - } -} diff --git a/database/migrations/2018_04_30_000000_add_parent_column.php b/database/migrations/2018_04_30_000000_add_parent_column.php deleted file mode 100644 index b12e3fe8c..000000000 --- a/database/migrations/2018_04_30_000000_add_parent_column.php +++ /dev/null @@ -1,56 +0,0 @@ -integer('parent_id')->default(0); - }); - - Schema::table('revenues', function (Blueprint $table) { - $table->integer('parent_id')->default(0); - }); - - Schema::table('bills', function (Blueprint $table) { - $table->integer('parent_id')->default(0); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->integer('parent_id')->default(0); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function (Blueprint $table) { - $table->dropColumn('parent_id'); - }); - - Schema::table('revenues', function (Blueprint $table) { - $table->dropColumn('parent_id'); - }); - - Schema::table('bills', function (Blueprint $table) { - $table->dropColumn('parent_id'); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->dropColumn('parent_id'); - }); - } -} diff --git a/database/migrations/2018_06_23_000000_modify_email_column.php b/database/migrations/2018_06_23_000000_modify_email_column.php deleted file mode 100644 index 9aa8f1719..000000000 --- a/database/migrations/2018_06_23_000000_modify_email_column.php +++ /dev/null @@ -1,42 +0,0 @@ -string('email')->nullable()->change(); - }); - - Schema::table('invoices', function (Blueprint $table) { - $table->string('customer_email')->nullable()->change(); - }); - - Schema::table('vendors', function (Blueprint $table) { - $table->string('email')->nullable()->change(); - }); - - Schema::table('bills', function (Blueprint $table) { - $table->string('vendor_email')->nullable()->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } -} diff --git a/database/migrations/2018_06_30_000000_modify_enabled_column.php b/database/migrations/2018_06_30_000000_modify_enabled_column.php deleted file mode 100644 index 992ea360b..000000000 --- a/database/migrations/2018_06_30_000000_modify_enabled_column.php +++ /dev/null @@ -1,50 +0,0 @@ -boolean('enabled')->default(1)->change(); - }); - - Schema::table('categories', function (Blueprint $table) { - $table->boolean('enabled')->default(1)->change(); - }); - - Schema::table('currencies', function (Blueprint $table) { - $table->boolean('enabled')->default(1)->change(); - }); - - Schema::table('items', function (Blueprint $table) { - $table->boolean('enabled')->default(1)->change(); - }); - - Schema::table('customers', function (Blueprint $table) { - $table->boolean('enabled')->default(1)->change(); - }); - - Schema::table('vendors', function (Blueprint $table) { - $table->boolean('enabled')->default(1)->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } -} diff --git a/database/migrations/2018_07_07_000000_modify_date_column.php b/database/migrations/2018_07_07_000000_modify_date_column.php deleted file mode 100644 index 9c9505c3c..000000000 --- a/database/migrations/2018_07_07_000000_modify_date_column.php +++ /dev/null @@ -1,56 +0,0 @@ -dateTime('billed_at')->change(); - $table->dateTime('due_at')->change(); - }); - - Schema::table('bill_payments', function (Blueprint $table) { - $table->dateTime('paid_at')->change(); - }); - - Schema::table('invoices', function (Blueprint $table) { - $table->dateTime('invoiced_at')->change(); - $table->dateTime('due_at')->change(); - }); - - Schema::table('invoice_payments', function (Blueprint $table) { - $table->dateTime('paid_at')->change(); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->dateTime('paid_at')->change(); - }); - - Schema::table('revenues', function (Blueprint $table) { - $table->dateTime('paid_at')->change(); - }); - - Schema::table('recurring', function (Blueprint $table) { - $table->dateTime('started_at')->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } -} diff --git a/database/migrations/2018_09_26_000000_add_reference_column_customers.php b/database/migrations/2018_09_26_000000_add_reference_column_customers.php deleted file mode 100644 index 550dd9c8a..000000000 --- a/database/migrations/2018_09_26_000000_add_reference_column_customers.php +++ /dev/null @@ -1,32 +0,0 @@ -string('reference')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('customers', function (Blueprint $table) { - $table->dropColumn('reference'); - }); - } -} diff --git a/database/migrations/2018_09_26_000000_add_reference_column_vendors.php b/database/migrations/2018_09_26_000000_add_reference_column_vendors.php deleted file mode 100644 index 49fea58e5..000000000 --- a/database/migrations/2018_09_26_000000_add_reference_column_vendors.php +++ /dev/null @@ -1,32 +0,0 @@ -string('reference')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('vendors', function (Blueprint $table) { - $table->dropColumn('reference'); - }); - } -} diff --git a/database/migrations/2018_10_22_000000_create_bill_item_taxes_table.php b/database/migrations/2018_10_22_000000_create_bill_item_taxes_table.php deleted file mode 100644 index b1244eec8..000000000 --- a/database/migrations/2018_10_22_000000_create_bill_item_taxes_table.php +++ /dev/null @@ -1,40 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('bill_id'); - $table->integer('bill_item_id'); - $table->integer('tax_id'); - $table->string('name'); - $table->double('amount', 15, 4)->default('0.0000'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('bill_item_taxes'); - } -} diff --git a/database/migrations/2018_10_22_000000_create_invoice_item_taxes_table.php b/database/migrations/2018_10_22_000000_create_invoice_item_taxes_table.php deleted file mode 100644 index 5d3e42e71..000000000 --- a/database/migrations/2018_10_22_000000_create_invoice_item_taxes_table.php +++ /dev/null @@ -1,40 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('invoice_id'); - $table->integer('invoice_item_id'); - $table->integer('tax_id'); - $table->string('name'); - $table->double('amount', 15, 4)->default('0.0000'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('invoice_item_taxes'); - } -} diff --git a/database/migrations/2018_10_27_000000_add_reconciled_column.php b/database/migrations/2018_10_27_000000_add_reconciled_column.php deleted file mode 100644 index 9175022d0..000000000 --- a/database/migrations/2018_10_27_000000_add_reconciled_column.php +++ /dev/null @@ -1,56 +0,0 @@ -boolean('reconciled')->default(0); - }); - - Schema::table('invoice_payments', function (Blueprint $table) { - $table->boolean('reconciled')->default(0); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->boolean('reconciled')->default(0); - }); - - Schema::table('revenues', function (Blueprint $table) { - $table->boolean('reconciled')->default(0); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('bill_payments', function (Blueprint $table) { - $table->dropColumn('reconciled'); - }); - - Schema::table('invoice_payments', function (Blueprint $table) { - $table->dropColumn('reconciled'); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->dropColumn('reconciled'); - }); - - Schema::table('revenues', function (Blueprint $table) { - $table->dropColumn('reconciled'); - }); - } -} diff --git a/database/migrations/2018_10_27_000000_create_reconciliations_table.php b/database/migrations/2018_10_27_000000_create_reconciliations_table.php deleted file mode 100644 index 7bc6939fe..000000000 --- a/database/migrations/2018_10_27_000000_create_reconciliations_table.php +++ /dev/null @@ -1,40 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->integer('account_id'); - $table->dateTime('started_at'); - $table->dateTime('ended_at'); - $table->double('closing_balance', 15, 4)->default('0.0000'); - $table->boolean('reconciled'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('reconciliations'); - } -} diff --git a/database/migrations/2018_11_05_000000_add_tax_columns.php b/database/migrations/2018_11_05_000000_add_tax_columns.php deleted file mode 100644 index 1e31d94a6..000000000 --- a/database/migrations/2018_11_05_000000_add_tax_columns.php +++ /dev/null @@ -1,34 +0,0 @@ -string('type')->default('normal'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('taxes', function (Blueprint $table) { - $table->dropColumn([ - 'type', - ]); - }); - } -} diff --git a/database/migrations/2019_01_07_000000_drop_tax_id_column.php b/database/migrations/2019_01_07_000000_drop_tax_id_column.php deleted file mode 100644 index e8352e10a..000000000 --- a/database/migrations/2019_01_07_000000_drop_tax_id_column.php +++ /dev/null @@ -1,40 +0,0 @@ -dropColumn('tax_id'); - }); - - Schema::table('invoice_items', function (Blueprint $table) { - $table->dropColumn('tax_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('bill_items', function (Blueprint $table) { - $table->integer('tax_id')->default(0); - }); - - Schema::table('invoice_items', function (Blueprint $table) { - $table->integer('tax_id')->default(0); - }); - } -} diff --git a/database/migrations/2019_02_04_000000_modify_deleted_at_column_media_table.php b/database/migrations/2019_02_04_000000_modify_deleted_at_column_media_table.php deleted file mode 100644 index ee6af9789..000000000 --- a/database/migrations/2019_02_04_000000_modify_deleted_at_column_media_table.php +++ /dev/null @@ -1,36 +0,0 @@ -dropUnique(['disk', 'directory', 'filename', 'extension']); - - $table->unique(['disk', 'directory', 'filename', 'extension', 'deleted_at']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('media', function (Blueprint $table) { - $table->dropUnique(['disk', 'directory', 'filename', 'extension', 'deleted_at']); - - $table->unique(['disk', 'directory', 'filename', 'extension']); - }); - } -} diff --git a/database/migrations/2019_11_14_000000_add_footer_column_invoices_table.php b/database/migrations/2019_11_14_000000_add_footer_column_invoices_table.php deleted file mode 100644 index 0e9beb20b..000000000 --- a/database/migrations/2019_11_14_000000_add_footer_column_invoices_table.php +++ /dev/null @@ -1,32 +0,0 @@ -text('footer')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function (Blueprint $table) { - $table->dropColumn('footer'); - }); - } -} diff --git a/database/migrations/2019_11_14_000000_create_contacts_table.php b/database/migrations/2019_11_14_000000_create_contacts_table.php deleted file mode 100644 index 926e866c5..000000000 --- a/database/migrations/2019_11_14_000000_create_contacts_table.php +++ /dev/null @@ -1,77 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('type'); - $table->string('name'); - $table->string('email')->nullable(); - $table->integer('user_id')->nullable(); - $table->string('tax_number')->nullable(); - $table->string('phone')->nullable(); - $table->text('address')->nullable(); - $table->string('website')->nullable(); - $table->string('currency_code', 3); - $table->boolean('enabled'); - $table->string('reference')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['company_id', 'type']); - $table->unique(['company_id', 'type', 'email', 'deleted_at']); - }); - - $rename_bills = [ - 'vendor_id' => 'contact_id', - 'vendor_name' => 'contact_name', - 'vendor_email' => 'contact_email', - 'vendor_tax_number' => 'contact_tax_number', - 'vendor_phone' => 'contact_phone', - 'vendor_address' => 'contact_address', - ]; - - foreach ($rename_bills as $from => $to) { - Schema::table('bills', function (Blueprint $table) use ($from, $to) { - $table->renameColumn($from, $to); - }); - } - - $rename_invoices = [ - 'customer_id' => 'contact_id', - 'customer_name' => 'contact_name', - 'customer_email' => 'contact_email', - 'customer_tax_number' => 'contact_tax_number', - 'customer_phone' => 'contact_phone', - 'customer_address' => 'contact_address', - ]; - - foreach ($rename_invoices as $from => $to) { - Schema::table('invoices', function (Blueprint $table) use ($from, $to) { - $table->renameColumn($from, $to); - }); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('contacts'); - } -} diff --git a/database/migrations/2019_11_14_000000_create_dashboards_table.php b/database/migrations/2019_11_14_000000_create_dashboards_table.php deleted file mode 100644 index 9b996ab1c..000000000 --- a/database/migrations/2019_11_14_000000_create_dashboards_table.php +++ /dev/null @@ -1,61 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('name'); - $table->boolean('enabled')->default(1); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['company_id']); - }); - - Schema::create('user_dashboards', function (Blueprint $table) { - $table->integer('user_id')->unsigned(); - $table->integer('dashboard_id')->unsigned(); - $table->string('user_type', 20); - - $table->primary(['user_id', 'dashboard_id', 'user_type']); - }); - - Schema::create('widgets', function (Blueprint $table) { - $table->increments('id'); - $table->integer('company_id'); - $table->integer('dashboard_id'); - $table->string('class'); - $table->string('name'); - $table->text('settings')->nullable(); - $table->integer('sort')->default(0); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['company_id', 'dashboard_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('dashboards'); - Schema::drop('user_dashboards'); - Schema::drop('widgets'); - } -} diff --git a/database/migrations/2019_11_14_000000_create_email_templates_table.php b/database/migrations/2019_11_14_000000_create_email_templates_table.php deleted file mode 100644 index 95dc5a354..000000000 --- a/database/migrations/2019_11_14_000000_create_email_templates_table.php +++ /dev/null @@ -1,40 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('alias'); - $table->string('subject'); - $table->text('body'); - $table->text('params')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - $table->unique(['company_id', 'alias', 'deleted_at']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('email_templates'); - } -} diff --git a/database/migrations/2019_11_14_000000_create_firewall_table.php b/database/migrations/2019_11_14_000000_create_firewall_table.php deleted file mode 100644 index a3fa1a982..000000000 --- a/database/migrations/2019_11_14_000000_create_firewall_table.php +++ /dev/null @@ -1,54 +0,0 @@ -increments('id'); - $table->string('ip'); - $table->integer('log_id')->nullable(); - $table->boolean('blocked')->default(1); - $table->timestamps(); - $table->softDeletes(); - - $table->index('ip'); - $table->unique(['ip', 'deleted_at']); - }); - - Schema::create('firewall_logs', function (Blueprint $table) { - $table->increments('id'); - $table->string('ip'); - $table->string('level')->default('medium'); - $table->string('middleware'); - $table->integer('user_id')->nullable(); - $table->string('url')->nullable(); - $table->string('referrer')->nullable(); - $table->text('request')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('ip'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('firewall_ips'); - Schema::drop('firewall_logs'); - } -} diff --git a/database/migrations/2019_11_14_000000_create_reports_table.php b/database/migrations/2019_11_14_000000_create_reports_table.php deleted file mode 100644 index 9a9809f7a..000000000 --- a/database/migrations/2019_11_14_000000_create_reports_table.php +++ /dev/null @@ -1,42 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('class'); - $table->string('name'); - $table->text('description'); - $table->string('group'); - $table->string('period'); - $table->string('basis'); - $table->string('chart'); - $table->timestamps(); - $table->softDeletes(); - - $table->index('company_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('reports'); - } -} diff --git a/database/migrations/2019_11_14_000000_create_transactions_table.php b/database/migrations/2019_11_14_000000_create_transactions_table.php deleted file mode 100644 index ed50c8312..000000000 --- a/database/migrations/2019_11_14_000000_create_transactions_table.php +++ /dev/null @@ -1,57 +0,0 @@ -increments('id'); - $table->integer('company_id'); - $table->string('type'); - $table->integer('account_id'); - $table->dateTime('paid_at'); - $table->double('amount', 15, 4); - $table->string('currency_code', 3); - $table->double('currency_rate', 15, 8); - $table->integer('document_id')->nullable(); - $table->integer('contact_id')->nullable(); - $table->text('description')->nullable(); - $table->integer('category_id'); - $table->string('payment_method'); - $table->string('reference')->nullable(); - $table->integer('parent_id')->default(0); - $table->boolean('reconciled')->default(0); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['company_id', 'type']); - }); - - Schema::table('transfers', function (Blueprint $table) { - $table->renameColumn('payment_id', 'expense_transaction_id'); - }); - - Schema::table('transfers', function (Blueprint $table) { - $table->renameColumn('revenue_id', 'income_transaction_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('transactions'); - } -} diff --git a/database/migrations/2019_11_14_000000_modify_domain_column_companies_table.php b/database/migrations/2019_11_14_000000_modify_domain_column_companies_table.php deleted file mode 100644 index 1ce134e32..000000000 --- a/database/migrations/2019_11_14_000000_modify_domain_column_companies_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('domain')->nullable()->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('companies', function (Blueprint $table) { - $table->string('domain')->change(); - }); - } -} diff --git a/database/migrations/2019_11_14_000000_modify_status_column_modules_table.php b/database/migrations/2019_11_14_000000_modify_status_column_modules_table.php deleted file mode 100644 index cd2b13206..000000000 --- a/database/migrations/2019_11_14_000000_modify_status_column_modules_table.php +++ /dev/null @@ -1,32 +0,0 @@ -renameColumn('status', 'enabled'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('modules', function (Blueprint $table) { - $table->renameColumn('enabled', 'status'); - }); - } -} diff --git a/database/migrations/2019_11_17_000000_modify_sku_quantity_column_items_table.php b/database/migrations/2019_11_17_000000_modify_sku_quantity_column_items_table.php deleted file mode 100644 index 76b0ea75a..000000000 --- a/database/migrations/2019_11_17_000000_modify_sku_quantity_column_items_table.php +++ /dev/null @@ -1,46 +0,0 @@ -string('sku')->nullable()->change(); - $table->integer('quantity')->default(1)->change(); - - $connection = Schema::getConnection(); - $d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items'); - - if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) { - // 1.3 update - $table->dropUnique('items_company_id_sku_deleted_at_unique'); - } else { - // 2.0 install - $table->dropUnique(['company_id', 'sku', 'deleted_at']); - } - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('items', function (Blueprint $table) { - $table->string('sku')->change(); - $table->integer('quantity')->change(); - $table->unique(['company_id', 'sku', 'deleted_at']); - }); - } -} diff --git a/database/migrations/2020_01_01_000000_add_locale_column.php b/database/migrations/2020_01_01_000000_add_locale_column.php deleted file mode 100644 index 9339d0b66..000000000 --- a/database/migrations/2020_01_01_000000_add_locale_column.php +++ /dev/null @@ -1,32 +0,0 @@ -string('locale')->default(config('app.locale')); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('locale'); - }); - } -} diff --git a/database/migrations/2020_01_08_000000_core_v200.php b/database/migrations/2020_01_08_000000_core_v200.php new file mode 100644 index 000000000..4f1a0dc46 --- /dev/null +++ b/database/migrations/2020_01_08_000000_core_v200.php @@ -0,0 +1,262 @@ +text('footer')->nullable(); + }); + + // Contacts + Schema::create('contacts', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('type'); + $table->string('name'); + $table->string('email')->nullable(); + $table->integer('user_id')->nullable(); + $table->string('tax_number')->nullable(); + $table->string('phone')->nullable(); + $table->text('address')->nullable(); + $table->string('website')->nullable(); + $table->string('currency_code', 3); + $table->boolean('enabled'); + $table->string('reference')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['company_id', 'type']); + $table->unique(['company_id', 'type', 'email', 'deleted_at']); + }); + + $rename_bills = [ + 'vendor_id' => 'contact_id', + 'vendor_name' => 'contact_name', + 'vendor_email' => 'contact_email', + 'vendor_tax_number' => 'contact_tax_number', + 'vendor_phone' => 'contact_phone', + 'vendor_address' => 'contact_address', + ]; + + foreach ($rename_bills as $from => $to) { + Schema::table('bills', function (Blueprint $table) use ($from, $to) { + $table->renameColumn($from, $to); + }); + } + + $rename_invoices = [ + 'customer_id' => 'contact_id', + 'customer_name' => 'contact_name', + 'customer_email' => 'contact_email', + 'customer_tax_number' => 'contact_tax_number', + 'customer_phone' => 'contact_phone', + 'customer_address' => 'contact_address', + ]; + + foreach ($rename_invoices as $from => $to) { + Schema::table('invoices', function (Blueprint $table) use ($from, $to) { + $table->renameColumn($from, $to); + }); + } + + // Dashboards + Schema::create('dashboards', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('name'); + $table->boolean('enabled')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['company_id']); + }); + + Schema::create('user_dashboards', function (Blueprint $table) { + $table->integer('user_id')->unsigned(); + $table->integer('dashboard_id')->unsigned(); + $table->string('user_type', 20); + + $table->primary(['user_id', 'dashboard_id', 'user_type']); + }); + + Schema::create('widgets', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->integer('dashboard_id'); + $table->string('class'); + $table->string('name'); + $table->text('settings')->nullable(); + $table->integer('sort')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['company_id', 'dashboard_id']); + }); + + // Email templates + Schema::create('email_templates', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('alias'); + $table->string('subject'); + $table->text('body'); + $table->text('params')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + $table->unique(['company_id', 'alias', 'deleted_at']); + }); + + // Firewall + Schema::create('firewall_ips', function (Blueprint $table) { + $table->increments('id'); + $table->string('ip'); + $table->integer('log_id')->nullable(); + $table->boolean('blocked')->default(1); + $table->timestamps(); + $table->softDeletes(); + + $table->index('ip'); + $table->unique(['ip', 'deleted_at']); + }); + + Schema::create('firewall_logs', function (Blueprint $table) { + $table->increments('id'); + $table->string('ip'); + $table->string('level')->default('medium'); + $table->string('middleware'); + $table->integer('user_id')->nullable(); + $table->string('url')->nullable(); + $table->string('referrer')->nullable(); + $table->text('request')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->index('ip'); + }); + + // Reports + Schema::create('reports', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('class'); + $table->string('name'); + $table->text('description'); + $table->string('group'); + $table->string('period'); + $table->string('basis'); + $table->string('chart'); + $table->timestamps(); + $table->softDeletes(); + + $table->index('company_id'); + }); + + // Transactions + Schema::create('transactions', function (Blueprint $table) { + $table->increments('id'); + $table->integer('company_id'); + $table->string('type'); + $table->integer('account_id'); + $table->dateTime('paid_at'); + $table->double('amount', 15, 4); + $table->string('currency_code', 3); + $table->double('currency_rate', 15, 8); + $table->integer('document_id')->nullable(); + $table->integer('contact_id')->nullable(); + $table->text('description')->nullable(); + $table->integer('category_id')->default(1); + $table->string('payment_method'); + $table->string('reference')->nullable(); + $table->integer('parent_id')->default(0); + $table->boolean('reconciled')->default(0); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['company_id', 'type']); + }); + + Schema::table('transfers', function (Blueprint $table) { + $table->renameColumn('payment_id', 'expense_transaction_id'); + }); + + Schema::table('transfers', function (Blueprint $table) { + $table->renameColumn('revenue_id', 'income_transaction_id'); + }); + + // Domain column + Schema::table('companies', function (Blueprint $table) { + $table->string('domain')->nullable()->change(); + }); + + // Status column + Schema::table('modules', function (Blueprint $table) { + $table->renameColumn('status', 'enabled'); + }); + + // Sku and quantity columns + Schema::table('items', function (Blueprint $table) { + $table->string('sku')->nullable()->change(); + $table->integer('quantity')->default(1)->change(); + + $connection = Schema::getConnection(); + $d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items'); + + if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) { + // 1.3 update + $table->dropUnique('items_company_id_sku_deleted_at_unique'); + } else { + // 2.0 install + $table->dropUnique(['company_id', 'sku', 'deleted_at']); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function (Blueprint $table) { + $table->dropColumn('footer'); + }); + + Schema::drop('contacts'); + Schema::drop('dashboards'); + Schema::drop('user_dashboards'); + Schema::drop('widgets'); + Schema::drop('email_templates'); + Schema::drop('firewall_ips'); + Schema::drop('firewall_logs'); + Schema::drop('reports'); + Schema::drop('transactions'); + + Schema::table('companies', function (Blueprint $table) { + $table->string('domain')->change(); + }); + + Schema::table('modules', function (Blueprint $table) { + $table->renameColumn('enabled', 'status'); + }); + + Schema::table('items', function (Blueprint $table) { + $table->string('sku')->change(); + $table->integer('quantity')->change(); + $table->unique(['company_id', 'sku', 'deleted_at']); + }); + } +} diff --git a/database/seeds/Settings.php b/database/seeds/Settings.php index d95b1f806..ecf81d0ee 100644 --- a/database/seeds/Settings.php +++ b/database/seeds/Settings.php @@ -4,7 +4,6 @@ namespace Database\Seeds; use App\Abstracts\Model; use Illuminate\Database\Seeder; -use Date; class Settings extends Seeder { @@ -28,8 +27,26 @@ class Settings extends Seeder setting()->setExtraColumns(['company_id' => $company_id]); + $offline_payments = []; + + $offline_payments[] = [ + 'code' => 'offline-payments.cash.1', + 'name' => trans('demo.offline_payments.cash'), + 'customer' => '0', + 'order' => '1', + 'description' => null, + ]; + + $offline_payments[] = [ + 'code' => 'offline-payments.bank_transfer.2', + 'name' => trans('demo.offline_payments.bank'), + 'customer' => '0', + 'order' => '2', + 'description' => null, + ]; + setting()->set([ - 'localisation.financial_start' => Date::now()->startOfYear()->format('d-m'), + 'localisation.financial_start' => now()->startOfYear()->format('d-m'), 'localisation.timezone' => 'Europe/London', 'localisation.date_format' => 'd M Y', 'localisation.date_separator' => 'space', @@ -54,7 +71,7 @@ class Settings extends Seeder 'schedule.bill_days' => '10,5,3,1', 'schedule.time' => '09:00', 'wizard.completed' => '0', - 'offline-payments.methods' => '[{"code":"offline-payments.cash.1","name":"Cash","order":"1","description":null},{"code":"offline-payments.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]', + 'offline-payments.methods' => json_encode($offline_payments), 'contact.type.customer' => 'customer', 'contact.type.vendor' => 'vendor', ]); diff --git a/modules/OfflinePayments/Database/Migrations/2017_09_19_delete_offline_file.php b/modules/OfflinePayments/Database/Migrations/2017_09_19_delete_offline_file.php deleted file mode 100644 index 90414dd76..000000000 --- a/modules/OfflinePayments/Database/Migrations/2017_09_19_delete_offline_file.php +++ /dev/null @@ -1,64 +0,0 @@ -get('version'), '1.0.0') == 0) { - $offline_payments = json_decode(setting('offline.payment.methods'), true); - - if (!empty($offline_payments)) { - $offlinepayment = array(); - - foreach ($offline_payments as $offline_payment) { - $code = explode('.', $offline_payment['code']); - - $offline_payment['code'] = $code[1]; - - $offlinepayment[] = array( - 'code' => 'offlinepayment.' . $code[1] . '.' . $code[2], - 'name' => $offline_payment['name'], - 'customer' => 0, - 'order' => $offline_payment['order'], - 'description' => $offline_payment['description'] - ); - } - - //$company_id = $this->command->argument('company'); - - // Set the active company settings - setting()->setExtraColumns(['company_id' => 1]); - - setting()->set('offline-payments.methods', json_encode($offlinepayment)); - - setting()->forget('offline.payment.methods'); - - setting()->save(); - } - - $module->delete(); - - Artisan::call('cache:clear'); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } -} \ No newline at end of file diff --git a/modules/OfflinePayments/Database/Seeders/OfflinePaymentDatabaseSeeder.php b/modules/OfflinePayments/Database/Seeders/OfflinePaymentDatabaseSeeder.php deleted file mode 100644 index cd8cf2aa7..000000000 --- a/modules/OfflinePayments/Database/Seeders/OfflinePaymentDatabaseSeeder.php +++ /dev/null @@ -1,47 +0,0 @@ -create(); - - Model::reguard(); - } - - private function create() - { - $methods = array(); - - $methods[] = array( - 'code' => 'offline-payments.cash.1', - 'name' => 'Cash', - 'customer' => '0', - 'order' => '1', - 'description' => null, - ); - - $methods[] = array( - 'code' => 'offline-payments.bank_transfer.2', - 'name' => 'Bank Transfer', - 'customer' => '0', - 'order' => '2', - 'description' => null, - ); - - Setting::set('offline-payments.methods', json_encode($methods)); - } -} diff --git a/modules/OfflinePayments/Providers/Main.php b/modules/OfflinePayments/Providers/Main.php index 767b68f49..cda09e9db 100644 --- a/modules/OfflinePayments/Providers/Main.php +++ b/modules/OfflinePayments/Providers/Main.php @@ -16,7 +16,6 @@ class Main extends Provider public function boot() { $this->loadTranslations(); - $this->loadMigrations(); $this->loadViews(); $this->loadEvents(); } @@ -51,16 +50,6 @@ class Main extends Provider $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'offline-payments'); } - /** - * Load migrations. - * - * @return void - */ - public function loadMigrations() - { - $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); - } - /** * Load events. * diff --git a/resources/lang/en-GB/demo.php b/resources/lang/en-GB/demo.php index c633b0c46..ad8b67591 100644 --- a/resources/lang/en-GB/demo.php +++ b/resources/lang/en-GB/demo.php @@ -18,6 +18,11 @@ return [ 'try' => 'Turkish Lira', ], + 'offline_payments' => [ + 'cash' => 'Cash', + 'bank' => 'Bank Transfer', + ], + 'reports' => [ 'income' => 'Monthly income summary by category.', 'expense' => 'Monthly expense summary by category.',