From a95548e455a142a7f835e1d38f125c202b2bbf95 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 21 Jun 2024 17:43:32 +1000 Subject: [PATCH] Redo database migrations for pgsql --- .env.example | 13 +- config/database.php | 2 +- .../migrations/0040-create_currencies.php | 41 ++ database/migrations/0042-create_countries.php | 44 ++ database/migrations/0044-create_languages.php | 33 + database/migrations/0046-create_taxes.php | 41 ++ database/migrations/0050-create_sites.php | 46 ++ ...raint.php => 0051-create_site_details.php} | 17 +- database/migrations/0092-create_users.php | 73 ++ .../migrations/0095-create_provider_oauth.php | 43 ++ database/migrations/0108-create_group.php | 47 ++ database/migrations/0109-create_rtm.php | 41 ++ database/migrations/0110-create_accounts.php | 67 ++ .../migrations/0111-create_account_group.php | 46 ++ database/migrations/0120-create_tld.php | 33 + .../0130-create_domain_registrar.php | 44 ++ database/migrations/0201-create_products.php | 46 ++ database/migrations/0202-create_services.php | 65 ++ .../0203-create_product_translate.php | 45 ++ .../migrations/0205-create_service_change.php | 50 ++ database/migrations/0210-create_charges.php | 61 ++ database/migrations/0213-create_suppliers.php | 83 +++ database/migrations/0215-create_costs.php | 45 ++ .../0217-create_supplier_host_server.php | 52 ++ database/migrations/0221-create_email.php | 87 +++ database/migrations/0223-create_ssl.php | 80 +++ database/migrations/0224-create_phone.php | 111 +++ database/migrations/0225-create_broadband.php | 144 ++++ database/migrations/0226-create_domain.php | 97 +++ database/migrations/0227-create_host.php | 91 +++ database/migrations/0228-create_generic.php | 99 +++ .../0235-create_usage_broadband.php | 52 ++ database/migrations/0240-create_checkout.php | 49 ++ database/migrations/0260-create_invoice.php | 48 ++ .../migrations/0261-create_invoice_item.php | 57 ++ .../0262-create_invoice_item_tax.php | 41 ++ .../0270-create_provider_tokens.php | 50 ++ .../migrations/0271-create_user_oauth.php | 47 ++ database/migrations/0280-create_payments.php | 55 ++ .../migrations/0281-create_payment_item.php | 45 ++ ...e.php => 0290-create_account_provider.php} | 45 +- ...2_100000_create_password_resets_table.php} | 20 +- ...104531_create_ab_account_billing_table.php | 43 ++ ..._18_104531_create_ab_account_log_table.php | 39 ++ ...18_104531_create_ab_account_memo_table.php | 40 ++ ...06_18_104531_create_ab_affiliate_table.php | 50 ++ ...6_18_104531_create_ab_asset_pool_table.php | 36 + ...017_06_18_104531_create_ab_asset_table.php | 42 ++ ...2017_06_18_104531_create_ab_cart_table.php | 41 ++ ...104531_create_ab_checkout_notify_table.php | 42 ++ ..._06_18_104531_create_ab_discount_table.php | 56 ++ ...06_18_104531_create_ab_email_log_table.php | 49 ++ ..._18_104531_create_ab_email_setup_table.php | 52 ++ ..._104531_create_ab_email_template_table.php | 40 ++ ...eate_ab_email_template_translate_table.php | 40 ++ ..._104531_create_ab_export_datamap_table.php | 44 ++ ..._18_104531_create_ab_export_item_table.php | 42 ++ ...8_104531_create_ab_export_module_table.php | 39 ++ ...17_06_18_104531_create_ab_export_table.php | 39 ++ ...18_104531_create_ab_group_method_table.php | 39 ++ ..._create_ab_host_server_affiliate_table.php | 40 ++ ...17_06_18_104531_create_ab_import_table.php | 41 ++ ..._create_ab_invoice_item_discount_table.php | 41 ++ ...18_104531_create_ab_invoice_memo_table.php | 41 ++ ...06_18_104531_create_ab_log_error_table.php | 39 ++ ...8_104531_create_ab_module_method_table.php | 41 ++ ...31_create_ab_module_method_token_table.php | 43 ++ ...17_06_18_104531_create_ab_module_table.php | 42 ++ ...4531_create_ab_pivot_product_cat_table.php | 39 ++ ..._18_104531_create_ab_product_cat_table.php | 41 ++ ..._create_ab_product_cat_translate_table.php | 40 ++ ...06_18_104531_create_ab_record_id_table.php | 36 + ...18_104531_create_ab_service_memo_table.php | 41 ++ ...8_104531_create_ab_setup_invoice_table.php | 50 ++ ...17_06_18_104531_create_ab_ssl_ca_table.php | 42 ++ .../2017_06_18_104531_create_ab_ssl_table.php | 35 + ...1_create_ab_static_page_category_table.php | 40 ++ ..._18_104531_create_ab_static_page_table.php | 43 ++ ..._create_ab_static_page_translate_table.php | 41 ++ ..._06_18_104531_create_ab_task_log_table.php | 39 ++ ...2017_06_18_104531_create_ab_task_table.php | 50 ++ .../2019_01_24_142111_create_jobs_table.php | 36 + ..._01_24_175606_create_failed_jobs_table.php | 35 + .../2021_07_09_141228_rework_domains.php | 35 - .../2021_07_23_164158_rework_payments.php | 56 -- .../2021_09_30_132207_rework_charges.php | 50 -- .../2021_12_17_131958_cleanup_site.php | 67 -- .../2021_12_17_162247_create_suppliers.php | 55 -- .../2021_12_20_000000_int_unsigned.php | 369 ---------- .../2021_12_20_225017_optimize_product.php | 632 ------------------ .../2022_04_02_092021_email_supplier.php | 106 --- ...022_04_19_121452_rename_service_tables.php | 345 ---------- .../2022_04_20_134953_rename_traffic.php | 42 -- .../2022_04_20_183016_updates_to_accounts.php | 48 -- ...022_04_22_122640_rename_invoice_tables.php | 124 ---- .../2022_04_22_144438_optimise_payments.php | 71 -- .../2022_06_10_164250_update_charges.php | 435 ------------ .../migrations/2022_06_13_230224_costs.php | 101 --- .../2022_07_29_151513_convert_checkout.php | 53 -- ..._08_02_155407_convert_domain_registrar.php | 70 -- .../2022_08_06_140410_supplier_constraint.php | 46 -- .../2022_08_11_101411_accounting.php | 111 --- .../2022_08_15_171005_qb_account_sync.php | 38 -- .../2022_08_19_133535_fix_siteid.php | 52 -- ...18_131249_domain_registrar_id_optional.php | 28 - ...8_223248_optimise_product_descriptions.php | 43 -- .../2023_05_03_223721_product_model.php | 32 - .../2023_05_04_100244_optimize_group.php | 124 ---- .../2023_05_05_104307_product_id_increase.php | 37 - ...023_05_05_234120_service_change_update.php | 100 --- ...3_05_10_172738_rename_account_provider.php | 38 -- .../2023_05_13_142113_accounting_payment.php | 38 -- 112 files changed, 3972 insertions(+), 3379 deletions(-) create mode 100644 database/migrations/0040-create_currencies.php create mode 100644 database/migrations/0042-create_countries.php create mode 100644 database/migrations/0044-create_languages.php create mode 100644 database/migrations/0046-create_taxes.php create mode 100644 database/migrations/0050-create_sites.php rename database/migrations/{2022_08_10_162636_supplier_user_constraint.php => 0051-create_site_details.php} (56%) create mode 100644 database/migrations/0092-create_users.php create mode 100644 database/migrations/0095-create_provider_oauth.php create mode 100644 database/migrations/0108-create_group.php create mode 100644 database/migrations/0109-create_rtm.php create mode 100644 database/migrations/0110-create_accounts.php create mode 100644 database/migrations/0111-create_account_group.php create mode 100644 database/migrations/0120-create_tld.php create mode 100644 database/migrations/0130-create_domain_registrar.php create mode 100644 database/migrations/0201-create_products.php create mode 100644 database/migrations/0202-create_services.php create mode 100644 database/migrations/0203-create_product_translate.php create mode 100644 database/migrations/0205-create_service_change.php create mode 100644 database/migrations/0210-create_charges.php create mode 100644 database/migrations/0213-create_suppliers.php create mode 100644 database/migrations/0215-create_costs.php create mode 100644 database/migrations/0217-create_supplier_host_server.php create mode 100644 database/migrations/0221-create_email.php create mode 100644 database/migrations/0223-create_ssl.php create mode 100644 database/migrations/0224-create_phone.php create mode 100644 database/migrations/0225-create_broadband.php create mode 100644 database/migrations/0226-create_domain.php create mode 100644 database/migrations/0227-create_host.php create mode 100644 database/migrations/0228-create_generic.php create mode 100644 database/migrations/0235-create_usage_broadband.php create mode 100644 database/migrations/0240-create_checkout.php create mode 100644 database/migrations/0260-create_invoice.php create mode 100644 database/migrations/0261-create_invoice_item.php create mode 100644 database/migrations/0262-create_invoice_item_tax.php create mode 100644 database/migrations/0270-create_provider_tokens.php create mode 100644 database/migrations/0271-create_user_oauth.php create mode 100644 database/migrations/0280-create_payments.php create mode 100644 database/migrations/0281-create_payment_item.php rename database/migrations/{2023_05_10_215107_accounting_invoice.php => 0290-create_account_provider.php} (61%) rename database/migrations/{2023_05_13_200404_unique_payment_item.php => 2014_10_12_100000_create_password_resets_table.php} (52%) create mode 100644 database/migrations/2017_06_18_104531_create_ab_account_billing_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_account_log_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_account_memo_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_affiliate_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_asset_pool_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_asset_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_cart_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_checkout_notify_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_discount_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_email_log_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_email_setup_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_email_template_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_email_template_translate_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_export_datamap_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_export_item_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_export_module_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_export_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_group_method_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_host_server_affiliate_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_import_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_invoice_item_discount_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_invoice_memo_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_log_error_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_module_method_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_module_method_token_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_module_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_pivot_product_cat_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_product_cat_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_product_cat_translate_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_record_id_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_service_memo_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_setup_invoice_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_ssl_ca_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_ssl_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_static_page_category_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_static_page_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_static_page_translate_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_task_log_table.php create mode 100644 database/migrations/2017_06_18_104531_create_ab_task_table.php create mode 100644 database/migrations/2019_01_24_142111_create_jobs_table.php create mode 100644 database/migrations/2019_01_24_175606_create_failed_jobs_table.php delete mode 100644 database/migrations/2021_07_09_141228_rework_domains.php delete mode 100644 database/migrations/2021_07_23_164158_rework_payments.php delete mode 100644 database/migrations/2021_09_30_132207_rework_charges.php delete mode 100644 database/migrations/2021_12_17_131958_cleanup_site.php delete mode 100644 database/migrations/2021_12_17_162247_create_suppliers.php delete mode 100644 database/migrations/2021_12_20_000000_int_unsigned.php delete mode 100644 database/migrations/2021_12_20_225017_optimize_product.php delete mode 100644 database/migrations/2022_04_02_092021_email_supplier.php delete mode 100644 database/migrations/2022_04_19_121452_rename_service_tables.php delete mode 100644 database/migrations/2022_04_20_134953_rename_traffic.php delete mode 100644 database/migrations/2022_04_20_183016_updates_to_accounts.php delete mode 100644 database/migrations/2022_04_22_122640_rename_invoice_tables.php delete mode 100644 database/migrations/2022_04_22_144438_optimise_payments.php delete mode 100644 database/migrations/2022_06_10_164250_update_charges.php delete mode 100644 database/migrations/2022_06_13_230224_costs.php delete mode 100644 database/migrations/2022_07_29_151513_convert_checkout.php delete mode 100644 database/migrations/2022_08_02_155407_convert_domain_registrar.php delete mode 100644 database/migrations/2022_08_06_140410_supplier_constraint.php delete mode 100644 database/migrations/2022_08_11_101411_accounting.php delete mode 100644 database/migrations/2022_08_15_171005_qb_account_sync.php delete mode 100644 database/migrations/2022_08_19_133535_fix_siteid.php delete mode 100644 database/migrations/2022_10_18_131249_domain_registrar_id_optional.php delete mode 100644 database/migrations/2022_10_18_223248_optimise_product_descriptions.php delete mode 100644 database/migrations/2023_05_03_223721_product_model.php delete mode 100644 database/migrations/2023_05_04_100244_optimize_group.php delete mode 100644 database/migrations/2023_05_05_104307_product_id_increase.php delete mode 100644 database/migrations/2023_05_05_234120_service_change_update.php delete mode 100644 database/migrations/2023_05_10_172738_rename_account_provider.php delete mode 100644 database/migrations/2023_05_13_142113_accounting_payment.php diff --git a/.env.example b/.env.example index a232809..351875c 100644 --- a/.env.example +++ b/.env.example @@ -8,12 +8,13 @@ APP_URL=https://www.graytech.net.au LOG_CHANNEL=stack -DB_CONNECTION=mysql -DB_HOST=database -DB_PORT=3306 -DB_DATABASE=database -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_CONNECTION=pgsql +DB_HOST=postgres +DB_PORT=5432 +DB_DATABASE=graytech +DB_USERNAME=graytech +DB_PASSWORD= +DB_SCHEMA=billing BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/config/database.php b/config/database.php index 199382d..4b884ae 100644 --- a/config/database.php +++ b/config/database.php @@ -74,7 +74,7 @@ return [ 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, - 'schema' => 'public', + 'schema' => env('DB_SCHEMA', 'public'), 'sslmode' => 'prefer', ], diff --git a/database/migrations/0040-create_currencies.php b/database/migrations/0040-create_currencies.php new file mode 100644 index 0000000..8ef234d --- /dev/null +++ b/database/migrations/0040-create_currencies.php @@ -0,0 +1,41 @@ +id(); + $table->boolean('active')->default(false); + + $table->string('iso', 3)->unique(); + $table->string('name', 191)->unique(); + $table->text('notes')->nullable(); + $table->text('rates')->nullable(); + $table->string('symbol', 2); + $table->smallInteger('rounding'); + + $table->unique(['id','iso']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('currencies'); + } +}; \ No newline at end of file diff --git a/database/migrations/0042-create_countries.php b/database/migrations/0042-create_countries.php new file mode 100644 index 0000000..c8266df --- /dev/null +++ b/database/migrations/0042-create_countries.php @@ -0,0 +1,44 @@ +id(); + $table->boolean('active')->default(false); + + $table->string('name', 191)->unique(); + $table->text('notes')->nullable(); + + $table->string('two_code', 2)->nullable()->unique(); + $table->string('three_code', 3)->unique(); + + $table->integer('currency_id')->unsigned()->nullable(); + $table->foreign(['currency_id'])->references(['id'])->on('currencies'); + + $table->unique(['id','currency_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('countries'); + } +}; \ No newline at end of file diff --git a/database/migrations/0044-create_languages.php b/database/migrations/0044-create_languages.php new file mode 100644 index 0000000..b3232cf --- /dev/null +++ b/database/migrations/0044-create_languages.php @@ -0,0 +1,33 @@ +id(); + $table->string('name', 45)->nullable()->unique(); + $table->string('iso', 5)->nullable()->unique(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('languages'); + } +}; \ No newline at end of file diff --git a/database/migrations/0046-create_taxes.php b/database/migrations/0046-create_taxes.php new file mode 100644 index 0000000..d87dfce --- /dev/null +++ b/database/migrations/0046-create_taxes.php @@ -0,0 +1,41 @@ +id(); + + $table->string('zone',128)->nullable(); + $table->text('description'); + $table->float('rate', 10, 0); + + $table->integer('country_id')->unsigned(); + $table->foreign(['country_id'])->references(['id'])->on('countries'); + + $table->unique(['id','country_id']); + $table->unique(['country_id','zone']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('taxes'); + } +}; \ No newline at end of file diff --git a/database/migrations/0050-create_sites.php b/database/migrations/0050-create_sites.php new file mode 100644 index 0000000..7584aaa --- /dev/null +++ b/database/migrations/0050-create_sites.php @@ -0,0 +1,46 @@ +id(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->integer('admin_id')->unsigned()->nullable(); + + $table->string('url',256)->unique(); + + $table->integer('country_id'); + $table->integer('currency_id'); + $table->foreign(['country_id','currency_id'])->references(['id','currency_id'])->on('countries'); + + $table->integer('language_id'); + $table->foreign('language_id')->references('id')->on('languages'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('sites'); + } +}; \ No newline at end of file diff --git a/database/migrations/2022_08_10_162636_supplier_user_constraint.php b/database/migrations/0051-create_site_details.php similarity index 56% rename from database/migrations/2022_08_10_162636_supplier_user_constraint.php rename to database/migrations/0051-create_site_details.php index 7b4e993..fabc088 100644 --- a/database/migrations/2022_08_10_162636_supplier_user_constraint.php +++ b/database/migrations/0051-create_site_details.php @@ -1,7 +1,7 @@ unique(['supplier_id','id']); + Schema::create('site_details', function (Blueprint $table) + { + $table->string('key'); + $table->string('value'); + + $table->integer('site_id')->unsigned(); + $table->foreign('site_id')->references('id')->on('sites'); + + $table->unique(['site_id','key']); }); } @@ -25,8 +32,6 @@ return new class extends Migration */ public function down() { - Schema::table('supplier_user', function (Blueprint $table) { - $table->dropUnique(['supplier_id','id']); - }); + Schema::dropIfExists('site_details'); } }; \ No newline at end of file diff --git a/database/migrations/0092-create_users.php b/database/migrations/0092-create_users.php new file mode 100644 index 0000000..2377956 --- /dev/null +++ b/database/migrations/0092-create_users.php @@ -0,0 +1,73 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('email', 256); + $table->string('password', 191)->nullable(); + $table->string('remember_token', 100)->nullable(); + $table->string('title', 8)->nullable(); + $table->string('firstname', 128); + $table->string('lastname', 128); + $table->string('address1', 128)->nullable(); + $table->string('address2', 128)->nullable(); + $table->string('city', 128)->nullable(); + $table->string('state', 64)->nullable(); + $table->string('postcode', 16)->nullable(); + $table->boolean('emailable')->default(1); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->integer('country_id')->unsigned(); + $table->foreign(['country_id'])->references(['id'])->on('countries'); + + $table->integer('language_id')->unsigned()->nullable(); + $table->foreign(['language_id'])->references(['id'])->on('languages'); + + $table->unique(['id','site_id']); + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['site_id','email']); + }); + + /* + */ + Schema::table('sites', function(Blueprint $table) { + $table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + /* + */ + Schema::table('sites', function(Blueprint $table) { + $table->dropForeign(['admin_id','site_id']); + }); + + Schema::drop('users'); + } +}; \ No newline at end of file diff --git a/database/migrations/0095-create_provider_oauth.php b/database/migrations/0095-create_provider_oauth.php new file mode 100644 index 0000000..b26f889 --- /dev/null +++ b/database/migrations/0095-create_provider_oauth.php @@ -0,0 +1,43 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',32); + $table->string('app_id',128); + $table->string('secret',128); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','name']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('provider_oauth'); + } +}; \ No newline at end of file diff --git a/database/migrations/0108-create_group.php b/database/migrations/0108-create_group.php new file mode 100644 index 0000000..492d71a --- /dev/null +++ b/database/migrations/0108-create_group.php @@ -0,0 +1,47 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->dateTime('start_at')->nullable(); + $table->dateTime('expire_at')->nullable(); + + $table->string('name',128)->unique(); + $table->boolean('pricing')->default(false); + $table->text('notes')->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + $table->integer('parent_id')->nullable(); + $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('groups'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('groups'); + } +}; \ No newline at end of file diff --git a/database/migrations/0109-create_rtm.php b/database/migrations/0109-create_rtm.php new file mode 100644 index 0000000..eae549e --- /dev/null +++ b/database/migrations/0109-create_rtm.php @@ -0,0 +1,41 @@ +id(); + $table->integer('site_id')->unsigned(); + + $table->string('name',64)->unique(); + $table->integer('account_id')->unsigned(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('rtm'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('rtm'); + } +}; \ No newline at end of file diff --git a/database/migrations/0110-create_accounts.php b/database/migrations/0110-create_accounts.php new file mode 100644 index 0000000..4ea5646 --- /dev/null +++ b/database/migrations/0110-create_accounts.php @@ -0,0 +1,67 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->date('expire_at')->nullable(); + $table->string('company')->nullable(); + $table->string('address1', 128)->nullable(); + $table->string('address2', 128)->nullable(); + $table->string('city', 32)->nullable(); + $table->string('state', 32)->nullable(); + $table->string('zip', 16)->nullable(); + + $table->integer('country_id')->unsigned(); + $table->foreign(['country_id'])->references(['id'])->on('countries'); + + $table->integer('rtm_id')->unsigned(); + $table->foreign(['rtm_id','site_id'])->references(['id','site_id'])->on('rtm'); + + $table->integer('user_id')->unsigned(); + $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + }); + + /* + */ + Schema::table('rtm', function(Blueprint $table) { + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + /* + */ + Schema::table('rtm', function(Blueprint $table) + { + $table->dropForeign(['account_id','site_id']); + $table->dropColumn('account_id'); + }); + + Schema::drop('accounts'); + } +}; \ No newline at end of file diff --git a/database/migrations/0111-create_account_group.php b/database/migrations/0111-create_account_group.php new file mode 100644 index 0000000..228237d --- /dev/null +++ b/database/migrations/0111-create_account_group.php @@ -0,0 +1,46 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->dateTime('start_at')->nullable(); + $table->dateTime('expire_at')->nullable(); + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->integer('group_id')->unsigned(); + $table->foreign(['group_id','site_id'])->references(['id','site_id'])->on('groups'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','group_id','account_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('account_group'); + } +}; \ No newline at end of file diff --git a/database/migrations/0120-create_tld.php b/database/migrations/0120-create_tld.php new file mode 100644 index 0000000..151e752 --- /dev/null +++ b/database/migrations/0120-create_tld.php @@ -0,0 +1,33 @@ +id(); + $table->timestamps(); + $table->string('name',64)->unique(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tlds'); + } +}; \ No newline at end of file diff --git a/database/migrations/0130-create_domain_registrar.php b/database/migrations/0130-create_domain_registrar.php new file mode 100644 index 0000000..18e5974 --- /dev/null +++ b/database/migrations/0130-create_domain_registrar.php @@ -0,0 +1,44 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',32); + $table->string('file',32)->nullable(); + $table->string('whitelabel_url', 256)->nullable(); + $table->string('whitelabel_ns', 1024)->nullable(); + $table->string('manage_url', 256)->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('domain_registrars'); + } +}; \ No newline at end of file diff --git a/database/migrations/0201-create_products.php b/database/migrations/0201-create_products.php new file mode 100644 index 0000000..bf41e27 --- /dev/null +++ b/database/migrations/0201-create_products.php @@ -0,0 +1,46 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->boolean('taxable')->default(true); + $table->integer('position')->nullable(); + $table->text('pricing'); + $table->integer('price_recur_default')->nullable(); + $table->boolean('price_recur_strict')->nullable(); + $table->integer('model_id'); + $table->string('model')->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('products'); + } +}; \ No newline at end of file diff --git a/database/migrations/0202-create_services.php b/database/migrations/0202-create_services.php new file mode 100644 index 0000000..f65aacc --- /dev/null +++ b/database/migrations/0202-create_services.php @@ -0,0 +1,65 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->boolean('suspend_billing')->default(false); + $table->boolean('external_billing')->default(false); + + $table->float('price', 10, 0)->nullable(); + $table->float('price_override', 10, 0)->nullable(); + $table->boolean('taxable')->default(true); + + $table->integer('recur_schedule')->nullable(); + $table->text('prod_attr')->nullable(); + + $table->string('model')->nullable(); + $table->string('order_status')->nullable(); + $table->text('order_info')->nullable(); + + $table->date('invoice_last_at')->nullable(); + $table->date('invoice_next_at')->nullable(); + $table->date('start_at')->nullable(); + $table->date('stop_at')->nullable(); + $table->integer('account_billing_id')->unsigned()->nullable(); // @todo To remove? + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->integer('ordered_by')->unsigned()->nullable(); + $table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users'); + + $table->integer('product_id')->unsigned(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('services'); + } +}; \ No newline at end of file diff --git a/database/migrations/0203-create_product_translate.php b/database/migrations/0203-create_product_translate.php new file mode 100644 index 0000000..3fe656d --- /dev/null +++ b/database/migrations/0203-create_product_translate.php @@ -0,0 +1,45 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('name_short',128); + $table->text('name_detail')->nullable(); + $table->text('description')->nullable(); + + $table->integer('language_id')->unsigned(); + $table->foreign(['language_id'])->references(['id'])->on('languages'); + + $table->integer('product_id')->unsigned(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->unique(['product_id','language_id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('product_translate'); + } +}; \ No newline at end of file diff --git a/database/migrations/0205-create_service_change.php b/database/migrations/0205-create_service_change.php new file mode 100644 index 0000000..dff47b7 --- /dev/null +++ b/database/migrations/0205-create_service_change.php @@ -0,0 +1,50 @@ +id(); + $table->timestamps(); + $table->boolean('active')->default(false); + $table->integer('site_id')->unsigned(); + + $table->boolean('complete')->default(false); + $table->date('ordered_at'); + $table->date('effective_at')->nullable(); + $table->text('notes')->nullable(); + + $table->integer('product_id')->unsigned(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('ordered_by')->unsigned(); + $table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('service__change'); + } +}; \ No newline at end of file diff --git a/database/migrations/0210-create_charges.php b/database/migrations/0210-create_charges.php new file mode 100644 index 0000000..6ec1964 --- /dev/null +++ b/database/migrations/0210-create_charges.php @@ -0,0 +1,61 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->boolean('processed')->default(false); + $table->integer('sweep_type')->nullable(); + $table->integer('type')->nullable(); + $table->float('amount', 10, 0)->nullable(); + $table->float('quantity', 10, 0)->nullable(); + $table->boolean('taxable')->default(true); + $table->binary('attributes', 65535)->nullable(); + $table->string('description', 128)->nullable(); + + $table->date('start_at')->nullable(); + $table->date('stop_at')->nullable(); + $table->date('charge_at')->nullable(); + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->integer('product_id')->unsigned()->nullable(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->integer('service_id')->unsigned()->nullable(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('user_id')->unsigned()->nullable(); + $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('charges'); + } +}; \ No newline at end of file diff --git a/database/migrations/0213-create_suppliers.php b/database/migrations/0213-create_suppliers.php new file mode 100644 index 0000000..6540b53 --- /dev/null +++ b/database/migrations/0213-create_suppliers.php @@ -0,0 +1,83 @@ +id(); + $table->timestamps(); + $table->boolean('active')->default(false); + + $table->string('name')->unique(); + $table->string('address1')->nullable(); + $table->string('address2')->nullable(); + $table->string('city')->nullable(); + $table->string('state')->nullable(); + $table->string('postcode',16)->nullable(); + + $table->date('usage_last')->nullable(); + }); + + Schema::create('supplier_details', function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + + $table->text('notes')->nullable(); + $table->string('accounts')->nullable(); + $table->string('support')->nullable(); + $table->string('payments')->nullable(); + $table->jsonb('connections')->nullable(); + + $table->integer('site_id')->unsigned(); + $table->foreign('site_id')->references('id')->on('sites'); + + $table->integer('supplier_id')->unsigned(); + $table->foreign('supplier_id')->references('id')->on('suppliers'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','supplier_id']); + }); + + Schema::create('supplier_user', function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->integer('supplier_id')->unsigned(); + $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); + + $table->integer('user_id')->unsigned(); + $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + $table->unique(['id','supplier_id']); + $table->unique(['supplier_id','user_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('supplier_user'); + Schema::dropIfExists('supplier_details'); + Schema::dropIfExists('suppliers'); + } +}; \ No newline at end of file diff --git a/database/migrations/0215-create_costs.php b/database/migrations/0215-create_costs.php new file mode 100644 index 0000000..b77756a --- /dev/null +++ b/database/migrations/0215-create_costs.php @@ -0,0 +1,45 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->date('billed_at'); + $table->string('invoice_num')->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->integer('supplier_id')->unsigned(); + $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + Schema::dropIfExists('costs'); + } +}; \ No newline at end of file diff --git a/database/migrations/0217-create_supplier_host_server.php b/database/migrations/0217-create_supplier_host_server.php new file mode 100644 index 0000000..86d95c0 --- /dev/null +++ b/database/migrations/0217-create_supplier_host_server.php @@ -0,0 +1,52 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->boolean('debug')->nullable(); + $table->string('name',128); + $table->string('notes')->nullable(); + $table->string('provision_plugin', 128)->nullable(); + $table->text('provision_plugin_data')->nullable(); + $table->integer('max_accounts')->nullable(); + $table->string('whitelabel_url', 256)->nullable(); + $table->string('manage_url', 256)->nullable(); + $table->string('manage_username', 45)->nullable(); + $table->string('manage_password', 45)->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->integer('supplier_id')->unsigned()->nullable(); + $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('supplier_host_servers'); + } +}; \ No newline at end of file diff --git a/database/migrations/0221-create_email.php b/database/migrations/0221-create_email.php new file mode 100644 index 0000000..f1f7fbe --- /dev/null +++ b/database/migrations/0221-create_email.php @@ -0,0 +1,87 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id'); + $table->string('product_desc')->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_email', function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + ; + $table->string('product_id'); + $table->string('product_desc')->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_email'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_email', function (Blueprint $table) + { + $table->id(); + $table->integer('site_id')->unsigned(); + + $table->string('domain_name',128); + $table->date('expire_at')->nullable(); + $table->string('admin_url')->nullable(); + $table->string('admin_user')->nullable(); + $table->string('admin_pass')->nullable(); + $table->integer('accounts')->nullable(); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('tld_id')->unsigned(); + $table->foreign('tld_id')->references('id')->on('tlds'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('service_email'); + Schema::dropIfExists('product_email'); + Schema::dropIfExists('supplier_email'); + } +}; \ No newline at end of file diff --git a/database/migrations/0223-create_ssl.php b/database/migrations/0223-create_ssl.php new file mode 100644 index 0000000..d7225ef --- /dev/null +++ b/database/migrations/0223-create_ssl.php @@ -0,0 +1,80 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id',16); + $table->string('product_desc',128)->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_ssl',function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',64); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_ssl'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_ssl', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->integer('ssl_ca_id')->unsigned()->nullable(); + $table->text('csr'); + $table->text('pk')->nullable(); + $table->text('cert')->nullable(); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('service_ssl'); + Schema::dropIfExists('product_ssl'); + Schema::dropIfExists('supplier_ssl'); + } +}; \ No newline at end of file diff --git a/database/migrations/0224-create_phone.php b/database/migrations/0224-create_phone.php new file mode 100644 index 0000000..5474740 --- /dev/null +++ b/database/migrations/0224-create_phone.php @@ -0,0 +1,111 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id',16); + $table->string('product_desc',128)->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + $table->string('technology')->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_phone',function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',64); + $table->integer('contract_term')->unsigned()->nullable(); + $table->string('technology')->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_phone'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_phone', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('service_number',10)->nullable(); + $table->string('service_address',128)->nullable(); + $table->string('service_username',128)->nullable(); + $table->string('service_password',32)->nullable(); + $table->string('technology')->nullable(); + + $table->date('connect_at')->nullable(); + $table->date('expire_at')->nullable(); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->unique(['id','site_id']); + }); + + Schema::create('cost_phone', function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->date('start_at')->nullable(); + $table->date('end_at')->nullable(); + $table->float('base')->nullable(); + $table->float('excess')->nullable(); + $table->string('reference')->nullable(); + $table->text('notes')->nullable(); + + $table->integer('cost_id')->unsigned(); + $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); + + $table->integer('service_phone_id')->unsigned()->nullable(); + $table->foreign(['service_phone_id','site_id'])->references(['id','site_id'])->on('service_phone'); + + $table->integer('supplier_phone_id')->unsigned()->nullable(); + $table->foreign(['supplier_phone_id','site_id'])->references(['id','site_id'])->on('supplier_phone'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cost_phone'); + Schema::dropIfExists('service_phone'); + Schema::dropIfExists('product_phone'); + Schema::dropIfExists('supplier_phone'); + } +}; \ No newline at end of file diff --git a/database/migrations/0225-create_broadband.php b/database/migrations/0225-create_broadband.php new file mode 100644 index 0000000..540efb5 --- /dev/null +++ b/database/migrations/0225-create_broadband.php @@ -0,0 +1,144 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id',32); + $table->text('product_desc')->nullable(); + + $table->integer('metric')->nullable(); + $table->string('speed',32)->nullable(); + $table->string('technology')->nullable(); + + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + $table->float('base_down_peak')->nullable(); + $table->float('base_up_peak')->nullable(); + $table->float('base_down_offpeak')->nullable(); + $table->float('base_up_offpeak')->nullable(); + $table->boolean('extra_charged')->default(false); + $table->boolean('extra_shaped')->default(false); + $table->float('extra_down_peak')->nullable(); + $table->float('extra_up_peak')->nullable(); + $table->float('extra_down_offpeak')->nullable(); + $table->float('extra_up_offpeak')->nullable(); + + $table->time('offpeak_start')->nullable(); + $table->time('offpeak_end')->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_broadband', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->integer('contract_term')->nullable(); + $table->float('base_down_peak', 10, 0)->nullable(); + $table->float('base_up_peak', 10, 0)->nullable(); + $table->float('base_down_offpeak', 10, 0)->nullable(); + $table->float('base_up_offpeak', 10, 0)->nullable(); + $table->boolean('extra_charged')->nullable(); + $table->string('extra_shaped', 8)->nullable(); + $table->float('extra_down_peak', 10, 0)->nullable(); + $table->float('extra_up_peak', 10, 0)->nullable(); + $table->float('extra_down_offpeak', 10, 0)->nullable(); + $table->float('extra_up_offpeak', 10, 0)->nullable(); + $table->float('metric', 10, 0)->default(0); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); + + $table->index(['id','site_id']); + }); + + Schema::create('service_broadband', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('service_number',16)->nullable(); + $table->string('service_address',256)->nullable(); + $table->string('service_username', 128)->nullable()->unique(); + $table->string('service_password', 16)->nullable(); + + $table->boolean('service_stats_collect')->default(true); + $table->date('service_stats_at')->nullable(); + + $table->string('ipaddress', 45)->nullable(); + $table->time('offpeak_start')->nullable(); + $table->time('offpeak_end')->nullable(); + + $table->date('connect_at')->nullable(); + $table->date('expire_at')->nullable(); + $table->ipAddress('ip6address')->nullable(); + $table->string('technology')->nullable(); + + $table->integer('provided_supplier_broadband_id')->unsigned()->nullable(); + $table->foreign(['provided_supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->unique(['id','site_id']); + }); + + Schema::create('cost_broadband', function (Blueprint $table) + { + $table->integer('id',TRUE,TRUE); + $table->integer('site_id')->unsigned(); + $table->integer('cost_id')->unsigned(); + $table->boolean('active'); + $table->integer('service_broadband_id')->unsigned()->nullable(); + $table->integer('supplier_broadband_id')->unsigned()->nullable(); + $table->date('start_at')->nullable(); + $table->date('end_at')->nullable(); + $table->float('base')->nullable(); + $table->float('excess')->nullable(); + $table->string('reference')->nullable(); + $table->text('notes')->nullable(); + + $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); + $table->foreign(['service_broadband_id','site_id'])->references(['id','site_id'])->on('service_broadband'); + $table->foreign(['supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('cost_broadband'); + Schema::drop('service_broadband'); + Schema::drop('product_broadband'); + Schema::drop('supplier_broadband'); + } +}; \ No newline at end of file diff --git a/database/migrations/0226-create_domain.php b/database/migrations/0226-create_domain.php new file mode 100644 index 0000000..408da8b --- /dev/null +++ b/database/migrations/0226-create_domain.php @@ -0,0 +1,97 @@ +id(); + $table->timestamps(); + $table->boolean('active')->default(false); + + $table->string('product_id',16); + $table->string('product_desc',128)->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + $table->text('whois_url')->nullable(); + $table->text('config')->nullable(); + + $table->integer('site_id')->unsigned(); + $table->foreign(['site_id'])->references(['id'])->on('sites'); + $table->integer('tld_id')->unsigned(); + $table->foreign(['tld_id'])->references(['id'])->on('tlds'); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_domain',function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',64); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_domain'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_domain', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('domain_name', 256); + + $table->date('expire_at')->nullable(); + + $table->string('registrar_account', 32)->nullable(); + $table->string('registrar_username', 128)->nullable(); + $table->string('registrar_auth_password', 128)->nullable(); + $table->string('registrar_ns', 1024)->nullable(); + + $table->integer('domain_registrar_id')->unsigned()->nullable(); + $table->foreign(['domain_registrar_id','site_id'])->references(['id','site_id'])->on('domain_registrars'); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('tld_id')->unsigned(); + $table->foreign(['tld_id'])->references(['id'])->on('tlds'); + + $table->unique(['id','site_id']); + $table->unique(['domain_name','tld_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('service_domain'); + Schema::drop('product_domain'); + Schema::drop('supplier_domain'); + } +}; \ No newline at end of file diff --git a/database/migrations/0227-create_host.php b/database/migrations/0227-create_host.php new file mode 100644 index 0000000..de4b330 --- /dev/null +++ b/database/migrations/0227-create_host.php @@ -0,0 +1,91 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id',16); + $table->string('product_desc',128)->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_host',function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',64); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_host'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_host', function(Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('domain_name', 128)->nullable(); + $table->string('host_type',16)->nullable(); + $table->string('host_username',45)->nullable(); + $table->string('host_password',45)->nullable(); + $table->string('ftp_username',16)->nullable(); + $table->string('ftp_password',16)->nullable(); + $table->binary('server_data',65535)->nullable(); + $table->date('expire_at')->nullable(); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('supplier_host_server_id')->unsigned()->nullable(); + $table->foreign(['supplier_host_server_id','site_id'])->references(['id','site_id'])->on('supplier_host_servers'); + + $table->integer('tld_id')->unsigned(); + $table->foreign(['tld_id'])->references(['id'])->on('tlds'); + + $table->unique(['id','site_id']); + $table->unique(['supplier_host_server_id','ftp_username']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('service_host'); + Schema::drop('product_host'); + Schema::drop('supplier_host'); + } +}; \ No newline at end of file diff --git a/database/migrations/0228-create_generic.php b/database/migrations/0228-create_generic.php new file mode 100644 index 0000000..5c4d957 --- /dev/null +++ b/database/migrations/0228-create_generic.php @@ -0,0 +1,99 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('product_id',16)->nullable(); + $table->string('product_desc',128)->nullable(); + $table->float('base_cost'); + $table->float('setup_cost')->nullable(); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_detail_id')->unsigned(); + $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); + + $table->unique(['id','site_id']); + }); + + Schema::create('product_generic',function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',64); + $table->integer('contract_term')->unsigned()->nullable(); + + $table->integer('supplier_item_id')->unsigned(); + $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_generic'); + + $table->unique(['id','site_id']); + }); + + Schema::create('service_generic', function (Blueprint $table) + { + $table->id(); + $table->integer('site_id')->unsigned(); + + $table->integer('service_id')->unsigned(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->integer('product_id')->unsigned()->nullable(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','service_id']); + }); + + Schema::create('cost_generic', function (Blueprint $table) + { + $table->integer('id',TRUE,TRUE); + $table->integer('site_id')->unsigned(); + $table->integer('cost_id')->unsigned(); + $table->boolean('active'); + $table->integer('service_generic_id')->unsigned()->nullable(); + $table->integer('supplier_generic_id')->unsigned()->nullable(); + $table->date('start_at')->nullable(); + $table->date('end_at')->nullable(); + $table->float('base')->nullable(); + $table->float('excess')->nullable(); + $table->string('reference')->nullable(); + $table->text('notes')->nullable(); + + $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); + $table->foreign(['service_generic_id','site_id'])->references(['id','site_id'])->on('service_generic'); + $table->foreign(['supplier_generic_id','site_id'])->references(['id','site_id'])->on('supplier_generic'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cost_generic'); + Schema::dropIfExists('service_generic'); + Schema::dropIfExists('product_generic'); + Schema::dropIfExists('supplier_generic'); + } +}; \ No newline at end of file diff --git a/database/migrations/0235-create_usage_broadband.php b/database/migrations/0235-create_usage_broadband.php new file mode 100644 index 0000000..0e51068 --- /dev/null +++ b/database/migrations/0235-create_usage_broadband.php @@ -0,0 +1,52 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->date('date'); + $table->time('time')->nullable(); + $table->string('service',128)->nullable(); + $table->integer('up_peak')->nullable(); + $table->integer('up_offpeak')->nullable(); + $table->integer('down_peak')->nullable(); + $table->integer('down_offpeak')->nullable(); + $table->integer('peer')->nullable(); + $table->integer('internal')->nullable(); + + $table->integer('service_item_id')->nullable(); + $table->foreign(['service_item_id','site_id'])->references(['id','site_id'])->on('service_broadband'); + + $table->integer('supplier_id'); // @todo To remove? + $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); + + $table->unique(['service_item_id','site_id','date','time']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('usage_broadband'); + } +}; \ No newline at end of file diff --git a/database/migrations/0240-create_checkout.php b/database/migrations/0240-create_checkout.php new file mode 100644 index 0000000..38d5b4c --- /dev/null +++ b/database/migrations/0240-create_checkout.php @@ -0,0 +1,49 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('name',32); + $table->string('description')->nullable(); + $table->string('plugin', 32)->nullable(); + $table->text('plugin_data')->nullable(); + $table->string('graphic_url', 128)->nullable(); + $table->float('amount_min', 10, 0)->default(0); + $table->float('amount_max', 10, 0)->nullable(); + $table->float('fee_fixed', 10, 0)->nullable(); + $table->float('fee_variable', 10, 0)->nullable(); + $table->boolean('fee_passon')->default(false); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('checkouts'); + } +}; \ No newline at end of file diff --git a/database/migrations/0260-create_invoice.php b/database/migrations/0260-create_invoice.php new file mode 100644 index 0000000..77416ad --- /dev/null +++ b/database/migrations/0260-create_invoice.php @@ -0,0 +1,48 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->date('due_at'); + + $table->boolean('process_status')->nullable(); + $table->boolean('billing_status')->nullable(); + $table->boolean('print_status')->default(false); + $table->integer('account_billing_id')->nullable(); + $table->float('discount_amt',10,0)->nullable(); + $table->binary('reminders', 65535)->nullable(); + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('invoices'); + } +}; \ No newline at end of file diff --git a/database/migrations/0261-create_invoice_item.php b/database/migrations/0261-create_invoice_item.php new file mode 100644 index 0000000..0d88de3 --- /dev/null +++ b/database/migrations/0261-create_invoice_item.php @@ -0,0 +1,57 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->date('start_at')->nullable(); + $table->date('stop_at')->nullable(); + + $table->integer('module_id')->nullable(); + $table->bigInteger('module_ref')->nullable(); + $table->float('quantity', 10, 0)->nullable(); + $table->integer('item_type')->nullable(); + $table->string('product_name', 128)->nullable(); + $table->float('discount_amt', 10, 0)->nullable(); + $table->float('price_base', 10, 0)->nullable(); + $table->integer('recur_schedule')->nullable(); + + $table->integer('invoice_id')->unsigned(); + $table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices'); + + $table->integer('product_id')->unsigned()->nullable(); + $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); + + $table->integer('service_id')->unsigned()->nullable(); + $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('invoice_items'); + } +}; \ No newline at end of file diff --git a/database/migrations/0262-create_invoice_item_tax.php b/database/migrations/0262-create_invoice_item_tax.php new file mode 100644 index 0000000..32e8677 --- /dev/null +++ b/database/migrations/0262-create_invoice_item_tax.php @@ -0,0 +1,41 @@ +id(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->float('amount',10,0); + + $table->integer('invoice_item_id')->unsigned(); + $table->foreign(['invoice_item_id','site_id'])->references(['id','site_id'])->on('invoice_items'); + + $table->integer('tax_id')->unsigned(); + $table->foreign('tax_id')->references('id')->on('taxes'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('invoice_item_taxes'); + } +}; \ No newline at end of file diff --git a/database/migrations/0270-create_provider_tokens.php b/database/migrations/0270-create_provider_tokens.php new file mode 100644 index 0000000..6b404a2 --- /dev/null +++ b/database/migrations/0270-create_provider_tokens.php @@ -0,0 +1,50 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->bigInteger('realm_id')->unsigned(); + + $table->text('access_token'); + $table->datetime('access_token_expires_at'); + + $table->string('refresh_token'); + $table->datetime('refresh_token_expires_at'); + + $table->integer('user_id')->unsigned(); + $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->integer('provider_oauth_id')->unsigned(); + $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); + + $table->unique(['id','site_id']); + $table->unique(['provider_oauth_id','user_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('provider_tokens'); + } +}; \ No newline at end of file diff --git a/database/migrations/0271-create_user_oauth.php b/database/migrations/0271-create_user_oauth.php new file mode 100644 index 0000000..5c14dbd --- /dev/null +++ b/database/migrations/0271-create_user_oauth.php @@ -0,0 +1,47 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + + $table->string('userid',128); + $table->binary('oauth_data', 65535)->nullable(); + + $table->integer('user_id')->unsigned()->nullable(); + + $table->integer('provider_oauth_id')->unsigned(); + $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); + + $table->index(['user_id','site_id']); + $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','user_id','provider_oauth_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('user_oauth'); + } +}; \ No newline at end of file diff --git a/database/migrations/0280-create_payments.php b/database/migrations/0280-create_payments.php new file mode 100644 index 0000000..db10890 --- /dev/null +++ b/database/migrations/0280-create_payments.php @@ -0,0 +1,55 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->string('checkout_data')->nullable(); + $table->float('total_amt', 10, 0); + $table->float('fees_amt', 10, 0)->nullable(); + $table->boolean('pending_status')->nullable(); + $table->text('notes', 65535)->nullable(); + $table->string('ip', 128)->nullable(); + $table->string('pending')->nullable(); + + $table->date('paid_at'); + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->integer('checkout_id')->unsigned(); + $table->foreign(['checkout_id','site_id'])->references(['id','site_id'])->on('checkouts'); + + $table->integer('source_id')->nullable(); + $table->foreign(['source_id','site_id'])->references(['id','site_id'])->on('users'); + + $table->unique(['id','site_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('payments'); + } +}; \ No newline at end of file diff --git a/database/migrations/0281-create_payment_item.php b/database/migrations/0281-create_payment_item.php new file mode 100644 index 0000000..b95bf69 --- /dev/null +++ b/database/migrations/0281-create_payment_item.php @@ -0,0 +1,45 @@ +id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->boolean('active')->default(false); + + $table->float('amount',10,0); + + $table->integer('invoice_id')->unsigned()->nullable(); + $table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices'); + + $table->integer('payment_id')->unsigned(); + $table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments'); + + $table->unique(['id','site_id']); + $table->unique(['site_id','invoice_id','payment_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('payment_items'); + } +}; \ No newline at end of file diff --git a/database/migrations/2023_05_10_215107_accounting_invoice.php b/database/migrations/0290-create_account_provider.php similarity index 61% rename from database/migrations/2023_05_10_215107_accounting_invoice.php rename to database/migrations/0290-create_account_provider.php index b5df327..6020be9 100644 --- a/database/migrations/2023_05_10_215107_accounting_invoice.php +++ b/database/migrations/0290-create_account_provider.php @@ -13,7 +13,23 @@ return new class extends Migration */ public function up() { - Schema::create('invoice__provider', function (Blueprint $table) { + Schema::create('account__provider', function (Blueprint $table) + { + $table->id(); + $table->timestamps(); + $table->integer('site_id')->unsigned(); + $table->string('ref'); + $table->integer('synctoken'); + + $table->integer('account_id')->unsigned(); + $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); + + $table->integer('provider_oauth_id')->unsigned(); + $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); + }); + + Schema::create('invoice__provider', function (Blueprint $table) + { $table->timestamps(); $table->integer('invoice_id')->unsigned(); $table->integer('provider_oauth_id')->unsigned(); @@ -25,7 +41,8 @@ return new class extends Migration $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); }); - Schema::create('product__provider', function (Blueprint $table) { + Schema::create('product__provider', function (Blueprint $table) + { $table->integer('product_id')->unsigned(); $table->integer('provider_oauth_id')->unsigned(); $table->integer('site_id')->unsigned(); @@ -35,7 +52,8 @@ return new class extends Migration $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); }); - Schema::create('tax__provider', function (Blueprint $table) { + Schema::create('tax__provider', function (Blueprint $table) + { $table->timestamps(); $table->integer('tax_id')->unsigned(); $table->integer('provider_oauth_id')->unsigned(); @@ -47,8 +65,17 @@ return new class extends Migration $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); }); - Schema::table('products', function (Blueprint $table) { - $table->dropColumn('accounting'); + Schema::create('payment__provider', function (Blueprint $table) + { + $table->timestamps(); + $table->integer('payment_id')->unsigned(); + $table->integer('provider_oauth_id')->unsigned(); + $table->integer('site_id')->unsigned(); + $table->string('ref'); + $table->integer('synctoken'); + + $table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments'); + $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); }); } @@ -59,12 +86,10 @@ return new class extends Migration */ public function down() { + Schema::dropIfExists('payment__provider'); Schema::dropIfExists('tax__provider'); Schema::dropIfExists('product__provider'); Schema::dropIfExists('invoice__provider'); - - Schema::table('products', function (Blueprint $table) { - $table->string('accounting'); - }); + Schema::dropIfExists('account__provider'); } -}; +}; \ No newline at end of file diff --git a/database/migrations/2023_05_13_200404_unique_payment_item.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php similarity index 52% rename from database/migrations/2023_05_13_200404_unique_payment_item.php rename to database/migrations/2014_10_12_100000_create_password_resets_table.php index 70a4726..0d5cb84 100644 --- a/database/migrations/2023_05_13_200404_unique_payment_item.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -1,10 +1,10 @@ unique(['site_id','payment_id','invoice_id']); - }); + Schema::create('password_resets', function (Blueprint $table) { + $table->string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); } /** @@ -25,8 +27,6 @@ return new class extends Migration */ public function down() { - Schema::table('payment_items', function (Blueprint $table) { - $table->dropUnique(['site_id','payment_id','invoice_id']); - }); + Schema::dropIfExists('password_resets'); } -}; +} diff --git a/database/migrations/2017_06_18_104531_create_ab_account_billing_table.php b/database/migrations/2017_06_18_104531_create_ab_account_billing_table.php new file mode 100644 index 0000000..e7deade --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_account_billing_table.php @@ -0,0 +1,43 @@ +integer('id'); + $table->integer('site_id'); + $table->bigInteger('account_id')->nullable(); + $table->integer('checkout_id'); + $table->bigInteger('service_id')->nullable(); + $table->binary('checkout_data', 65535)->nullable(); + $table->float('checkout_amount', 10, 0)->nullable(); + $table->string('notes', 128)->nullable(); + $table->primary(['id','site_id','checkout_id']); + $table->unique(['site_id','service_id']); + $table->index(['account_id','site_id']); + $table->index(['service_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_account_billing'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_account_log_table.php b/database/migrations/2017_06_18_104531_create_ab_account_log_table.php new file mode 100644 index 0000000..d7e3c14 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_account_log_table.php @@ -0,0 +1,39 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('account_id')->default(0); + $table->string('ip', 32)->nullable(); + $table->string('details', 256)->nullable(); + $table->primary(['id','site_id','account_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_account_log'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_account_memo_table.php b/database/migrations/2017_06_18_104531_create_ab_account_memo_table.php new file mode 100644 index 0000000..0bd8b73 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_account_memo_table.php @@ -0,0 +1,40 @@ +bigInteger('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('staff_id')->nullable(); + $table->bigInteger('account_id')->nullable()->index('account'); + $table->string('type', 32)->nullable(); + $table->string('memo')->nullable()->index('memo'); + $table->string('misc', 32)->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_account_memo'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_affiliate_table.php b/database/migrations/2017_06_18_104531_create_ab_affiliate_table.php new file mode 100644 index 0000000..7fbecfc --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_affiliate_table.php @@ -0,0 +1,50 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->boolean('active')->nullable(); + $table->bigInteger('account_id')->default(0); + $table->text('avail_campaign_id')->nullable(); + $table->string('affiliate_plugin', 32)->nullable(); + $table->string('parent_affiliate_id', 16)->nullable(); + $table->integer('max_tiers')->nullable(); + $table->float('commission_minimum', 10, 0)->nullable(); + $table->boolean('new_commission_type')->nullable(); + $table->text('new_commission_rate')->nullable(); + $table->boolean('recurr_commission_type')->nullable(); + $table->text('recurr_commission_rate')->nullable(); + $table->integer('recurr_max_commission_periods')->nullable(); + $table->text('plugin_data')->nullable(); + $table->primary(['id','site_id','account_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_affiliate'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_asset_pool_table.php b/database/migrations/2017_06_18_104531_create_ab_asset_pool_table.php new file mode 100644 index 0000000..5aa04a6 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_asset_pool_table.php @@ -0,0 +1,36 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->string('name', 32)->nullable(); + $table->unique(['site_id','id']); + $table->index(['id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_asset_pool'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_asset_table.php b/database/migrations/2017_06_18_104531_create_ab_asset_table.php new file mode 100644 index 0000000..b24c4e4 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_asset_table.php @@ -0,0 +1,42 @@ +bigInteger('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->boolean('active')->nullable(); + $table->bigInteger('service_id')->nullable()->index('service'); + $table->integer('pool_id')->nullable()->index('asso'); + $table->string('asset', 128)->nullable()->index('asset'); + $table->string('misc')->nullable(); + $table->unique(['site_id','id']); + $table->index(['id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_asset'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_cart_table.php b/database/migrations/2017_06_18_104531_create_ab_cart_table.php new file mode 100644 index 0000000..2aca2cb --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_cart_table.php @@ -0,0 +1,41 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->string('session_id', 32)->default(''); + $table->integer('quantity')->nullable(); + $table->integer('module_id')->default(0); + $table->integer('module_item')->default(0); + $table->text('module_data', 65535)->nullable(); + $table->primary(['id','site_id']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_cart'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_checkout_notify_table.php b/database/migrations/2017_06_18_104531_create_ab_checkout_notify_table.php new file mode 100644 index 0000000..eb0f060 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_checkout_notify_table.php @@ -0,0 +1,42 @@ +bigInteger('id'); + $table->integer('site_id'); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->integer('checkout_id'); + $table->boolean('active')->nullable(); + $table->binary('data', 65535); + $table->boolean('processed')->nullable(); + $table->text('result', 65535)->nullable(); + $table->primary(['id','site_id','checkout_id']); + $table->index(['checkout_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_checkout_notify'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_discount_table.php b/database/migrations/2017_06_18_104531_create_ab_discount_table.php new file mode 100644 index 0000000..582dcf8 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_discount_table.php @@ -0,0 +1,56 @@ +bigInteger('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->boolean('active')->nullable()->index(); + $table->bigInteger('date_start')->nullable()->index(); + $table->bigInteger('date_expire')->nullable()->index(); + $table->string('name', 64)->nullable(); + $table->text('notes')->nullable(); + $table->integer('max_usage_account')->nullable(); + $table->integer('max_usage_global')->nullable(); + $table->bigInteger('avail_account_id')->nullable(); + $table->text('avail_product_id')->nullable(); + $table->text('avail_group_id')->nullable(); + $table->text('avail_tld_id')->nullable(); + $table->boolean('new_status')->nullable(); + $table->boolean('new_type')->nullable(); + $table->float('new_rate', 10, 0)->nullable(); + $table->float('new_max_discount', 10, 0)->nullable(); + $table->float('new_min_cost', 10, 0)->nullable(); + $table->boolean('recurr_status')->nullable(); + $table->boolean('recurr_type')->nullable(); + $table->float('recurr_rate', 10, 0)->nullable(); + $table->float('recurr_max_discount', 10, 0)->nullable(); + $table->float('recurr_min_cost', 10, 0)->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_discount'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_email_log_table.php b/database/migrations/2017_06_18_104531_create_ab_email_log_table.php new file mode 100644 index 0000000..e36a01d --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_email_log_table.php @@ -0,0 +1,49 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('account_id')->default(0); + $table->bigInteger('email_template_translate_id')->nullable(); + $table->string('email', 128)->nullable(); + $table->string('subject', 128)->nullable(); + $table->text('message')->nullable(); + $table->boolean('html')->nullable(); + $table->boolean('urgent')->nullable(); + $table->boolean('userread')->nullable(); + $table->binary('data', 65535)->nullable(); + $table->integer('module_id')->nullable(); + $table->string('module_data', 128)->nullable(); + $table->primary(['id','site_id','account_id']); + $table->index(['email_template_translate_id','site_id']); + $table->index(['account_id','site_id']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_email_log'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_email_setup_table.php b/database/migrations/2017_06_18_104531_create_ab_email_setup_table.php new file mode 100644 index 0000000..c11d73c --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_email_setup_table.php @@ -0,0 +1,52 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('account_id')->default(0); + $table->string('name', 128)->nullable(); + $table->text('notes')->nullable(); + $table->boolean('type')->nullable(); + $table->string('from_name', 128)->nullable(); + $table->string('from_email', 128)->nullable(); + $table->text('cc_list')->nullable(); + $table->text('bcc_list')->nullable(); + $table->string('server', 128)->nullable(); + $table->string('username', 128)->nullable(); + $table->string('password', 128)->nullable(); + $table->string('piping', 4)->nullable(); + $table->string('piping_host', 128)->nullable(); + $table->string('piping_username', 128)->nullable(); + $table->string('piping_password', 128)->nullable(); + $table->string('piping_action', 4)->nullable(); + $table->boolean('queue')->nullable(); + $table->primary(['id','site_id','account_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_email_setup'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_email_template_table.php b/database/migrations/2017_06_18_104531_create_ab_email_template_table.php new file mode 100644 index 0000000..ae4ea1f --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_email_template_table.php @@ -0,0 +1,40 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->boolean('active')->nullable(); + $table->integer('email_setup_id')->default(0); + $table->string('name', 128)->nullable(); + $table->string('description', 32)->nullable(); + $table->text('notes')->nullable(); + $table->primary(['id','site_id','email_setup_id']); + $table->index(['email_setup_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_email_template'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_email_template_translate_table.php b/database/migrations/2017_06_18_104531_create_ab_email_template_translate_table.php new file mode 100644 index 0000000..8577117 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_email_template_translate_table.php @@ -0,0 +1,40 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('email_template_id')->default(0); + $table->integer('language_id')->default(0)->index(); + $table->string('subject'); + $table->text('message_text'); + $table->text('message_html')->nullable(); + $table->primary(['id','site_id','email_template_id','language_id']); + $table->index(['email_template_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_email_template_translate'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_export_datamap_table.php b/database/migrations/2017_06_18_104531_create_ab_export_datamap_table.php new file mode 100644 index 0000000..65aa8f3 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_export_datamap_table.php @@ -0,0 +1,44 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('export_module_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->boolean('active')->nullable(); + $table->bigInteger('item_id')->nullable(); + $table->integer('module_id'); + $table->binary('map_data', 65535)->nullable(); + $table->primary(['id','site_id','export_module_id','module_id']); + $table->unique(['item_id','export_module_id','site_id']); + $table->index(['export_module_id','site_id']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_export_datamap'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_export_item_table.php b/database/migrations/2017_06_18_104531_create_ab_export_item_table.php new file mode 100644 index 0000000..ab4366b --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_export_item_table.php @@ -0,0 +1,42 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('export_module_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->bigInteger('item_id')->default(0); + $table->string('reference', 64)->nullable(); + $table->string('crc', 128)->nullable(); + $table->primary(['id','site_id','export_module_id']); + $table->unique(['site_id','export_module_id','item_id']); + $table->index(['export_module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_export_item'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_export_module_table.php b/database/migrations/2017_06_18_104531_create_ab_export_module_table.php new file mode 100644 index 0000000..30bc3c8 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_export_module_table.php @@ -0,0 +1,39 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('export_id')->default(0); + $table->integer('module_id')->default(0); + $table->binary('display', 65535)->nullable(); + $table->primary(['id','site_id','export_id','module_id']); + $table->index(['export_id','site_id']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_export_module'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_export_table.php b/database/migrations/2017_06_18_104531_create_ab_export_table.php new file mode 100644 index 0000000..fd50151 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_export_table.php @@ -0,0 +1,39 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0)->index(); + $table->string('name', 128)->default(''); + $table->string('plugin', 128)->default(''); + $table->boolean('active')->nullable(); + $table->string('url', 128)->nullable(); + $table->primary(['id','site_id']); + $table->unique(['site_id','name']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_export'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_group_method_table.php b/database/migrations/2017_06_18_104531_create_ab_group_method_table.php new file mode 100644 index 0000000..a8bb8db --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_group_method_table.php @@ -0,0 +1,39 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->integer('method_id')->default(0); + $table->integer('group_id')->default(0); + $table->primary(['id','site_id','method_id','group_id']); + $table->unique(['id','site_id']); + $table->index(['method_id','site_id']); + $table->index(['group_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_group_method'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_host_server_affiliate_table.php b/database/migrations/2017_06_18_104531_create_ab_host_server_affiliate_table.php new file mode 100644 index 0000000..2cf8803 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_host_server_affiliate_table.php @@ -0,0 +1,40 @@ +bigInteger('id'); + $table->integer('site_id'); + $table->bigInteger('affiliate_id'); + $table->integer('host_server_id'); + $table->string('host_username', 45)->nullable(); + $table->string('host_password', 45)->nullable(); + $table->primary(['id','site_id','affiliate_id','host_server_id']); + $table->index(['affiliate_id','site_id']); + $table->index(['host_server_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_host_server_affiliate'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_import_table.php b/database/migrations/2017_06_18_104531_create_ab_import_table.php new file mode 100644 index 0000000..57edb5d --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_import_table.php @@ -0,0 +1,41 @@ +bigInteger('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->string('plugin', 32)->nullable(); + $table->string('action', 32)->nullable(); + $table->string('remote_table', 32)->nullable(); + $table->string('ab_table', 32)->nullable(); + $table->bigInteger('remote_id')->nullable(); + $table->bigInteger('ab_id')->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_import'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_invoice_item_discount_table.php b/database/migrations/2017_06_18_104531_create_ab_invoice_item_discount_table.php new file mode 100644 index 0000000..ccca30f --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_invoice_item_discount_table.php @@ -0,0 +1,41 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable()->index(); + $table->bigInteger('invoice_id')->nullable(); + $table->bigInteger('account_id')->nullable()->index(); + $table->bigInteger('invoice_item_id')->nullable(); + $table->string('discount', 64)->nullable()->index(); + $table->float('amount', 10, 0)->nullable(); + $table->unique(['site_id','id'], ); + $table->index(['invoice_id','invoice_item_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_invoice_item_discount'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_invoice_memo_table.php b/database/migrations/2017_06_18_104531_create_ab_invoice_memo_table.php new file mode 100644 index 0000000..bc68d5e --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_invoice_memo_table.php @@ -0,0 +1,41 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('invoice_id')->default(0); + $table->bigInteger('account_id')->nullable(); + $table->string('type', 32)->nullable(); + $table->binary('memo', 65535)->nullable(); + $table->primary(['id','site_id','invoice_id']); + $table->index(['invoice_id','site_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_invoice_memo'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_log_error_table.php b/database/migrations/2017_06_18_104531_create_ab_log_error_table.php new file mode 100644 index 0000000..24db5e5 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_log_error_table.php @@ -0,0 +1,39 @@ +bigInteger('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('account_id')->nullable(); + $table->string('module', 64)->nullable(); + $table->string('method', 64)->nullable(); + $table->text('message')->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_log_error'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_module_method_table.php b/database/migrations/2017_06_18_104531_create_ab_module_method_table.php new file mode 100644 index 0000000..9675593 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_module_method_table.php @@ -0,0 +1,41 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->integer('module_id')->default(0); + $table->string('name', 64)->nullable()->default(''); + $table->string('notes', 128)->nullable(); + $table->string('menu_display', 32)->nullable(); + $table->primary(['id','site_id','module_id']); + $table->unique(['id','site_id']); + $table->unique(['site_id','module_id','name']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_module_method'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_module_method_token_table.php b/database/migrations/2017_06_18_104531_create_ab_module_method_token_table.php new file mode 100644 index 0000000..8c274f5 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_module_method_token_table.php @@ -0,0 +1,43 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->integer('method_id')->default(0); + $table->bigInteger('account_id')->default(0); + $table->string('token', 36)->default(''); + $table->bigInteger('date_orig')->default(0); + $table->bigInteger('date_last')->nullable(); + $table->bigInteger('date_expire')->nullable(); + $table->string('uses', 45)->nullable(); + $table->primary(['id','site_id','method_id','account_id']); + $table->index(['method_id','site_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_module_method_token'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_module_table.php b/database/migrations/2017_06_18_104531_create_ab_module_table.php new file mode 100644 index 0000000..170c025 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_module_table.php @@ -0,0 +1,42 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0)->index(); + $table->string('name', 128)->default(''); + $table->bigInteger('date_orig')->nullable(); + $table->boolean('active')->nullable(); + $table->integer('parent_id')->nullable(); + $table->text('notes')->nullable(); + $table->boolean('external')->nullable(); + $table->primary(['id','site_id']); + $table->unique(['site_id','name']); + $table->index(['parent_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_module'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_pivot_product_cat_table.php b/database/migrations/2017_06_18_104531_create_ab_pivot_product_cat_table.php new file mode 100644 index 0000000..ca14931 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_pivot_product_cat_table.php @@ -0,0 +1,39 @@ +bigInteger('id', false); + $table->integer('site_id'); + $table->bigInteger('product_id')->nullable(); + $table->integer('product_cat_id')->nullable(); + $table->primary(['id','site_id']); + $table->unique(['site_id','product_id','product_cat_id']); + $table->index(['product_cat_id','site_id']); + $table->index(['product_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_pivot_product_cat'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_product_cat_table.php b/database/migrations/2017_06_18_104531_create_ab_product_cat_table.php new file mode 100644 index 0000000..db4a796 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_product_cat_table.php @@ -0,0 +1,41 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0)->index(); + $table->integer('parent_id')->nullable()->index(); + $table->binary('group_avail', 65535)->nullable(); + $table->binary('notes', 65535)->nullable(); + $table->boolean('active')->nullable(); + $table->string('template', 128)->nullable(); + $table->integer('position')->nullable(); + $table->integer('recur_schedule')->default(0); + $table->primary(['id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_product_cat'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_product_cat_translate_table.php b/database/migrations/2017_06_18_104531_create_ab_product_cat_translate_table.php new file mode 100644 index 0000000..912018f --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_product_cat_translate_table.php @@ -0,0 +1,40 @@ +integer('id')->default(0); + $table->integer('site_id')->default(0); + $table->integer('product_cat_id')->default(0); + $table->integer('language_id')->default(0)->index(); + $table->string('name', 128)->nullable(); + $table->binary('description', 65535)->nullable(); + $table->primary(['id','site_id','product_cat_id','language_id']); + $table->unique(['site_id','product_cat_id','language_id']); + $table->index(['product_cat_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_product_cat_translate'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_record_id_table.php b/database/migrations/2017_06_18_104531_create_ab_record_id_table.php new file mode 100644 index 0000000..21c60ac --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_record_id_table.php @@ -0,0 +1,36 @@ +integer('site_id')->default(0)->index(); + $table->integer('module_id')->default(0); + $table->integer('id')->default(0); + $table->primary(['site_id','module_id']); + $table->index(['module_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_record_id'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_service_memo_table.php b/database/migrations/2017_06_18_104531_create_ab_service_memo_table.php new file mode 100644 index 0000000..e784515 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_service_memo_table.php @@ -0,0 +1,41 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('service_id')->default(0); + $table->bigInteger('account_id')->nullable(); + $table->string('type', 32)->nullable(); + $table->binary('memo', 65535)->nullable(); + $table->primary(['id','site_id','service_id']); + $table->index(['service_id','site_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_service_memo'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_setup_invoice_table.php b/database/migrations/2017_06_18_104531_create_ab_setup_invoice_table.php new file mode 100644 index 0000000..711ef38 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_setup_invoice_table.php @@ -0,0 +1,50 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->boolean('bill_to_company')->nullable(); + $table->string('invoice_currency', 8)->nullable(); + $table->integer('invoice_decimals')->nullable(); + $table->integer('items_summary_max')->nullable(); + $table->text('news', 65535)->nullable(); + $table->string('page_type', 8)->nullable(); + $table->integer('invoice_delivery')->nullable(); + $table->boolean('invoice_show_itemized')->nullable(); + $table->boolean('invoice_show_service_dates')->nullable(); + $table->integer('invoice_grace')->nullable(); + $table->integer('invoice_advance_gen')->nullable(); + $table->integer('invoice_terms')->nullable(); + $table->string('invoice_pdf_plugin', 16)->nullable(); + $table->string('contact_us_url', 64)->nullable(); + $table->string('contact_us_phone', 64)->nullable(); + $table->integer('advance_notice')->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_setup_invoice'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_ssl_ca_table.php b/database/migrations/2017_06_18_104531_create_ab_ssl_ca_table.php new file mode 100644 index 0000000..5cdfff9 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_ssl_ca_table.php @@ -0,0 +1,42 @@ +bigInteger('id'); + $table->integer('site_id'); + $table->bigInteger('account_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->boolean('active')->nullable(); + $table->text('sign_pk', 65535); + $table->text('sign_cert', 65535); + $table->bigInteger('parent_ssl_ca_id')->nullable(); + $table->primary(['id','site_id','account_id']); + $table->index(['parent_ssl_ca_id','site_id']); + $table->index(['account_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_ssl_ca'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_ssl_table.php b/database/migrations/2017_06_18_104531_create_ab_ssl_table.php new file mode 100644 index 0000000..aa67d1e --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_ssl_table.php @@ -0,0 +1,35 @@ +bigInteger('id'); + $table->integer('site_id')->index(); + $table->string('extensions', 64); + $table->primary(['id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_ssl'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_static_page_category_table.php b/database/migrations/2017_06_18_104531_create_ab_static_page_category_table.php new file mode 100644 index 0000000..0b9c961 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_static_page_category_table.php @@ -0,0 +1,40 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->string('group_avail')->nullable(); + $table->string('name', 128)->nullable()->index(); + $table->text('description')->nullable(); + $table->boolean('active')->nullable()->index(); + $table->integer('sort_order')->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_static_page_category'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_static_page_table.php b/database/migrations/2017_06_18_104531_create_ab_static_page_table.php new file mode 100644 index 0000000..f616ed6 --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_static_page_table.php @@ -0,0 +1,43 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->integer('static_page_category_id')->nullable()->index(); + $table->bigInteger('date_start')->nullable()->index(); + $table->bigInteger('date_expire')->nullable()->index(); + $table->integer('sort_order')->nullable(); + $table->boolean('active')->nullable(); + $table->string('name', 128)->nullable()->index(); + $table->text('description')->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_static_page'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_static_page_translate_table.php b/database/migrations/2017_06_18_104531_create_ab_static_page_translate_table.php new file mode 100644 index 0000000..6ed853c --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_static_page_translate_table.php @@ -0,0 +1,41 @@ +integer('id')->nullable(); + $table->integer('site_id')->nullable(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->integer('static_page_id')->nullable(); + $table->string('language_id', 16)->nullable(); + $table->text('body_intro')->nullable(); + $table->text('body_full')->nullable(); + $table->string('title', 128)->nullable(); + $table->unique(['site_id','id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_static_page_translate'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_task_log_table.php b/database/migrations/2017_06_18_104531_create_ab_task_log_table.php new file mode 100644 index 0000000..8da52bb --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_task_log_table.php @@ -0,0 +1,39 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('task_id')->default(0); + $table->integer('result')->nullable(); + $table->binary('message', 65535)->nullable(); + $table->primary(['id','site_id','task_id']); + $table->index(['task_id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_task_log'); + } + +} diff --git a/database/migrations/2017_06_18_104531_create_ab_task_table.php b/database/migrations/2017_06_18_104531_create_ab_task_table.php new file mode 100644 index 0000000..05d4afb --- /dev/null +++ b/database/migrations/2017_06_18_104531_create_ab_task_table.php @@ -0,0 +1,50 @@ +bigInteger('id')->default(0); + $table->integer('site_id')->default(0)->index(); + $table->bigInteger('date_orig')->nullable(); + $table->bigInteger('date_last')->nullable(); + $table->bigInteger('date_run')->nullable(); + $table->integer('active')->nullable(); + $table->string('name', 32)->nullable(); + $table->string('description')->nullable(); + $table->boolean('log')->nullable(); + $table->integer('type')->nullable(); + $table->string('command', 128)->nullable(); + $table->string('int_min', 32)->nullable(); + $table->string('int_hour', 32)->nullable(); + $table->string('int_month', 32)->nullable(); + $table->string('int_month_day', 32)->nullable(); + $table->string('int_week_day', 32)->nullable(); + $table->boolean('running')->nullable(); + $table->string('running_host', 4)->nullable(); + $table->primary(['id','site_id']); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('ab_task'); + } + +} diff --git a/database/migrations/2019_01_24_142111_create_jobs_table.php b/database/migrations/2019_01_24_142111_create_jobs_table.php new file mode 100644 index 0000000..58d7715 --- /dev/null +++ b/database/migrations/2019_01_24_142111_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} diff --git a/database/migrations/2019_01_24_175606_create_failed_jobs_table.php b/database/migrations/2019_01_24_175606_create_failed_jobs_table.php new file mode 100644 index 0000000..d432dff --- /dev/null +++ b/database/migrations/2019_01_24_175606_create_failed_jobs_table.php @@ -0,0 +1,35 @@ +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/2021_07_09_141228_rework_domains.php b/database/migrations/2021_07_09_141228_rework_domains.php deleted file mode 100644 index b7223c6..0000000 --- a/database/migrations/2021_07_09_141228_rework_domains.php +++ /dev/null @@ -1,35 +0,0 @@ -renameColumn('registrar_type','registrar_account'); - $table->unique(['domain_name','domain_tld_id']); - $table->dropColumn(['registrar_password','registrar_pending_transfer']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -} diff --git a/database/migrations/2021_07_23_164158_rework_payments.php b/database/migrations/2021_07_23_164158_rework_payments.php deleted file mode 100644 index 7587c73..0000000 --- a/database/migrations/2021_07_23_164158_rework_payments.php +++ /dev/null @@ -1,56 +0,0 @@ -dropUnique('UNIQUE'); - $table->dropForeign('fk_pi_pay'); - $table->dropPrimary(['id','payment_id','site_id']); - $table->dropIndex('fk_pi_pay_idx'); - }); - - DB::statement('ALTER TABLE ab_payment_item RENAME TO payment_items'); - - - Schema::table('ab_payment', function (Blueprint $table) { - $table->dropPrimary(['id','checkout_id','account_id','site_id']); - $table->dropUnique('UNIQUE'); - }); - - DB::statement('ALTER TABLE ab_payment RENAME TO payments'); - - DB::statement('ALTER TABLE payment_items ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment'); - DB::statement('ALTER TABLE payments ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment'); - DB::statement('ALTER TABLE payments RENAME COLUMN date_payment TO payment_date'); - - Schema::table('payment_items', function (Blueprint $table) { - $table->unique(['site_id','payment_id','invoice_id']); - $table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments'); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->unique(['site_id','id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -} diff --git a/database/migrations/2021_09_30_132207_rework_charges.php b/database/migrations/2021_09_30_132207_rework_charges.php deleted file mode 100644 index d498495..0000000 --- a/database/migrations/2021_09_30_132207_rework_charges.php +++ /dev/null @@ -1,50 +0,0 @@ -dropForeign('fk_chg_acc'); - $table->dropForeign('fk_chg_pdt'); - $table->dropForeign('fk_chg_svc'); - $table->dropIndex('fk_chg_acc_idx'); - $table->dropIndex('fk_chg_svc_idx'); - $table->dropIndex('fk_chg_pdt_idx'); - $table->dropPrimary(['id','account_id','site_id']); - }); - - DB::statement('ALTER TABLE ab_charge RENAME TO charges'); - DB::statement('ALTER TABLE charges RENAME COLUMN date_charge TO charge_date'); - - Schema::table('charges', function (Blueprint $table) { - $table->unique(['id','account_id','site_id']); - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('ab_service'); - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('ab_product'); - $table->integer('user_id')->unsigned()->nullable(); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - }); - - DB::statement('ALTER TABLE charges MODIFY COLUMN id INT auto_increment'); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -} diff --git a/database/migrations/2021_12_17_131958_cleanup_site.php b/database/migrations/2021_12_17_131958_cleanup_site.php deleted file mode 100644 index 405986b..0000000 --- a/database/migrations/2021_12_17_131958_cleanup_site.php +++ /dev/null @@ -1,67 +0,0 @@ -dropColumn(['date_orig']); - }); - - DB::statement('ALTER TABLE ab_country RENAME TO countries'); - DB::statement('ALTER TABLE countries MODIFY id int(11) NOT NULL;'); - DB::statement('ALTER TABLE countries MODIFY name varchar(128) NOT NULL;'); - DB::statement('ALTER TABLE countries MODIFY notes text DEFAULT NULL;'); - - DB::statement('ALTER TABLE ab_currency RENAME TO currencies'); - DB::statement('ALTER TABLE currencies MODIFY id int(11) NOT NULL;'); - DB::statement('ALTER TABLE currencies MODIFY name varchar(128) NOT NULL;'); - DB::statement('ALTER TABLE currencies MODIFY notes text DEFAULT NULL;'); - DB::statement('ALTER TABLE currencies RENAME COLUMN convert_array TO rates;'); - - DB::statement('ALTER TABLE ab_language RENAME TO languages'); - - Schema::table('countries', function (Blueprint $table) { - $table->dropColumn(['description']); - - $table->foreign(['currency_id'])->references(['id'])->on('currencies'); - }); - - Schema::table('currencies', function (Blueprint $table) { - $table->dropForeign('fk_cur_cty'); - $table->dropIndex('fk_cur_cty_idx'); - $table->dropColumn(['country_id']); - }); - - DB::statement('ALTER TABLE ab_tax RENAME TO taxes'); - DB::statement('ALTER TABLE taxes MODIFY description text DEFAULT NULL;'); - DB::statement('ALTER TABLE taxes MODIFY id int(11) NOT NULL;'); - DB::statement('ALTER TABLE taxes MODIFY country_id int(11) NOT NULL;'); - Schema::table('taxes', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','tax_id_collect','tax_id_name','tax_id_req','tax_id_exempt','tax_id_regex']); - $table->dropIndex('fk_tax_cty_idx'); - $table->dropForeign('fk_tax_cty'); - - $table->foreign(['country_id'])->references(['id'])->on('countries'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -} diff --git a/database/migrations/2021_12_17_162247_create_suppliers.php b/database/migrations/2021_12_17_162247_create_suppliers.php deleted file mode 100644 index ceb7c6e..0000000 --- a/database/migrations/2021_12_17_162247_create_suppliers.php +++ /dev/null @@ -1,55 +0,0 @@ -integer('id',TRUE)->unsigned(); - $table->boolean('active'); - $table->string('name')->unique(); - $table->string('address1'); - $table->string('address2')->nullable(); - $table->string('city',64); - $table->string('state',32); - $table->string('postcode',8); - }); - - Schema::create('supplier_details', function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->text('notes')->nullable(); - $table->string('accounts')->nullable(); - $table->string('support')->nullable(); - $table->string('payments')->nullable(); - - $table->integer('supplier_id')->unsigned(); - $table->integer('site_id'); - - $table->unique(['supplier_id','site_id']); - - $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('supplier_details'); - Schema::dropIfExists('suppliers'); - } -} diff --git a/database/migrations/2021_12_20_000000_int_unsigned.php b/database/migrations/2021_12_20_000000_int_unsigned.php deleted file mode 100644 index 00b9110..0000000 --- a/database/migrations/2021_12_20_000000_int_unsigned.php +++ /dev/null @@ -1,369 +0,0 @@ - ['fk_ab_a','fk_ab_s'], - 'ab_account_group' => ['fk_ag_acc','fk_ag_grp'], - 'ab_account_log' => ['fk_al_acc'], - 'ab_account_oauth' => ['fk_ao_a','fk_ao_o','site_user_id'], - 'ab_adsl_plan' => ['fk_ap_asp'], - 'ab_adsl_supplier' => ['fk_as_set'], - 'ab_adsl_supplier_plan' => ['fk_asp_as'], - 'ab_affiliate' => ['fk_aff_acc'], - 'ab_cart' => ['fk_mod_crt'], - 'ab_checkout' => ['fk_cko_set'], - 'ab_checkout_notify' => ['fk_cn_c'], - 'ab_domain_tld' => ['fk_ht_hrp'], - 'ab_email_log' => ['fk_el_acc','fk_el_ett','fk_el_mod'], - 'ab_email_setup' => ['fk_es_acc'], - 'ab_email_template' => ['fk_et_es'], - 'ab_email_template_translate' => ['fk_emt_et','fk_emt_lan'], - 'ab_export' => ['fk_exp_set'], - 'ab_export_datamap' => ['fk_edm_exm','fk_edm_mod'], - 'ab_export_item' => ['fk_eit_exm'], - 'ab_export_module' => ['fk_exm_exp','fk_exm_mod'], - 'ab_group' => ['fk_grp_set'], - 'ab_group_method' => ['fk_gm_grp','fk_gm_mm'], - 'ab_host_server_affiliate' => ['fk_hsa_aff','fk_hsa_hs'], - 'ab_invoice' => ['fk_inv_acc'], - 'ab_invoice_item' => ['fk_ii_inv','fk_ii_mod','fk_ii_pdt','fk_ii_svc'], - 'ab_invoice_item_tax' => ['fk_iit_ii','fk_iit_tax'], - 'ab_invoice_memo' => ['fk_im_acc','fk_im_inv'], - 'ab_module' => ['fk_mod','fk_mod_set'], - 'ab_module_method' => ['fk_mm_mod'], - 'ab_module_method_token' => ['fk_mmt_acc','fk_mmt_mm'], - 'ab_oauth' => ['fk_o_set'], - 'ab_pivot_product_cat' => ['fk_p','fk_pc'], - 'ab_product' => ['fk_pdt_set'], - 'ab_product_cat_translate' => ['fk_pct_lan','fk_pct_pc'], - 'ab_product_cat' => ['fk_pc_pc','fk_pc_set'], - 'ab_product_translate' => ['fk_pt_l','fk_pt_p'], - 'ab_record_id' => ['fk_rid_mod','fk_rid_set'], - 'rtm' => ['fk_rtm_acc','fk_rtm_rtm'], - 'ab_service__adsl_traffic' => ['ab_service__adsl_traffic_ab_service_adsl_id_foreign','fk_sat_as'], - 'ab_service__adsl' => ['fk_sa_ap','fk_sa_svc'], - 'ab_service__hosting' => ['fk_sh_svc','fk_sh_ht','fk_sh_hs'], - 'ab_service__ssl' => ['fk_ss_sca','fk_ss_svc'], - 'ab_service_change' => ['fk_sc_a','fk_sc_p','fk_sc_s'], - 'ab_service_memo' => ['fk_sm_acc','fk_sm_svc'], - 'ab_service' => ['ab_service_orderby_id_foreign','fk_svc_acc','fk_svc_grp'], - 'ab_ssl' => ['fk_ssl_set'], - 'ab_ssl_ca' => ['fk_sca','fk_sca_acc'], - 'ab_task_log' => ['fk_tl_t'], - 'ab_task' => ['fk_tsk_set'], - 'accounts' => ['ab_account_user_id_foreign','fk_acc_cty','fk_acc_cur','fk_acc_lan','fk_acc_rtm','fk_acc_set'], - 'charges' => ['charges_account_id_site_id_foreign','charges_product_id_site_id_foreign','charges_service_id_site_id_foreign','charges_user_id_site_id_foreign'], - 'countries' => ['countries_currency_id_foreign'], - 'external_account' => ['external_account_account_id_foreign','external_account_external_integration_id_foreign','external_account_site_id_foreign'], - 'external_integrations' => ['external_integrations_user_id_foreign'], - 'payment_items' => ['fk_pi_inv','payment_items_payment_id_site_id_foreign'], - 'payments' => ['fk_pay_acc','fk_pay_acc_b','fk_pay_co'], - 'quickbooks_tokens' => ['quickbooks_tokens_user_id_foreign'], - 'service__generic' => ['service__generic_product_id_site_id_foreign','service__generic_service_id_site_id_foreign','service__generic_site_id_foreign'], - 'service_domains' => ['fk_sd_hrp','fk_sd_ht','fk_sd_svc'], - 'site_details' => ['site_details_site_id_foreign'], - 'sites' => ['sites_admin_id_site_id_foreign','sites_country_id_foreign','sites_currency_id_foreign','sites_language_id_foreign'], - 'supplier_details' => ['supplier_details_site_id_foreign','supplier_details_supplier_id_foreign'], - 'taxes' => ['taxes_country_id_foreign'], - 'users' => ['users_currency_id_foreign','users_language_id_foreign','users_parent_id_foreign'], - ]; - $indexes = [ - 'ab_account_billing' => ['fk_ab_a','fk_ab_s','UNIQUE'], - 'ab_account_group' => ['fk_ag_acc_idx','fk_ag_grp_idx','UNIQUE'], - 'ab_account_log' => ['fk_al_acc_idx'], - 'ab_account_memo' => ['memo','account','IDS'], - 'ab_account_oauth' => ['fk_ao_a_idx','fk_ao_o_idx','site_user_id_idx','ab_account_oauth_site_id_user_id_oauth_id_unique','UNIQUE'], - 'ab_adsl_supplier_plan' => ['fk_asp_as_idx'], - 'ab_adsl_supplier' => ['fk_as_set_idx'], - 'ab_adsl_plan' => ['fk_ap_asp_idx'], - 'ab_affiliate' => ['fk_aff_acc_idx'], - 'ab_asset_pool' => ['main','IDS'], - 'ab_asset' => ['assets','asso','service','asset','IDS'], - 'ab_cart' => ['fk_mod_crt_idx'], - 'ab_checkout_notify' => ['fk_cn_c_idx'], - 'ab_checkout' => ['fk_cko_set_idx'], - 'ab_discount' => ['start','expire','status','IDS'], - 'ab_domain_registrar' => ['fk_hrp_set','IDS'], - 'ab_domain_tld' => ['fk_ht_hrp_idx'], - 'ab_email_log' => ['fk_el_acc_idx','fk_el_ett_idx','fk_el_mod_idx'], - 'ab_email_setup' => ['fk_es_acc_idx'], - 'ab_email_template_translate' => ['fk_emt_et_idx','fk_emt_lan_idx'], - 'ab_email_template' => ['fk_et_es_idx'], - 'ab_export_datamap' => ['fk_edm_mod_idx','fk_edm_mod_idx1','UNIQUE'], - 'ab_export_item' => ['fk_exp_eit_idx','UNIQUE'], - 'ab_export_module' => ['fk_exp_exm_idx','fk_exp_mod_idx'], - 'ab_export' => ['fk_exp_set_idx','UNIQUE'], - 'ab_group_method' => ['fk_gm_grp_idx','fk_gm_mm_idx','UNIQUE'], - 'ab_group' => ['fk_grp_set_idx'], - 'ab_host_server' => ['IDS'], - 'ab_host_server_affiliate' => ['fk_hsa_aff_idx','fk_hsa_hs_idx'], - 'ab_import' => ['IDS'], - 'ab_invoice_item_discount' => ['discounts','invoice_id','dates','accounts','IDS'], - 'ab_invoice_item_tax' => ['fk_iit_ii_idx','fk_iit_tax_idx'], - 'ab_invoice_item' => ['fk_ii_inv_idx','fk_ii_mod_idx','fk_ii_pdt_idx','fk_ii_svc_idx','UNIQUE'], - 'ab_invoice_memo' => ['fk_im_acc_idx','fk_im_inv_idx'], - 'ab_invoice' => ['fk_inv_acc_idx'], - 'ab_log_error' => ['IDS'], - 'ab_module_method_token' => ['fk_mmt_acc_idx','fk_mmt_mm_idx'], - 'ab_module_method' => ['fk_mm_mod_idx','UNIQUE','UNIQUE2'], - 'ab_module' => ['fk_mod_idx','fk_mod_set_idx','UNIQUE'], - 'ab_oauth' => ['fk_o_set_idx','ab_oauth_site_id_name_unique'], - 'ab_pivot_product_cat' => ['fk_p_idx','fk_pc_idx','UNIQUE'], - 'ab_product_cat' => ['fk_pc_pc_idx','fk_pc_set_idx'], - 'ab_product' => ['fk_pdt_set_idx'], - 'ab_product_cat_translate' => ['fk_pct_lan_idx','fk_pct_pc_idx','UNIQUE'], - 'ab_product_translate' => ['fk_pt_l_idx','fk_pt_p_idx','UNIQUE'], - 'ab_record_id' => ['fk_rid_mod_idx','fk_rid_set_idx'], - 'rtm' => ['fk_rtm_set_idx','fk_rtm_acc_p_idx','uq_name'], - 'ab_service' => ['ab_service_orderby_id_foreign','fk_svc_acc_idx','fk_svc_grp_idx','UNIQUE'], - 'ab_service__adsl' => ['fk_service_number','fk_sa_svc_idx','fk_sa_ap_idx','uq_service_username','UNIQUE'], - 'ab_service__adsl_traffic' => ['fk_sat_as_idx','in_sat_SERVICE_DATE','in_sat_DATE','in_sat_SERVICE','ab_service__adsl_traffic_ab_service_adsl_id_date_time_unique'], - 'ab_service__hosting' => ['fk_sh_hs_idx','fk_domain_tld_id','fk_service_id','uq_ftp_username','UNIQUE'], - 'ab_service__ssl' => ['fk_ss_sca_idx','fk_ss_svc_idx','UNIQUE'], - 'ab_service_change' => ['fk_s_sc_idx','fk_s_p_idx','fk_sc_a_idx'], - 'ab_service_memo' => ['fk_sm_acc_idx','fk_sm_svc_idx'], - 'ab_setup_invoice' => ['IDS'], - 'ab_ssl' => ['fk_ssl_set_idx'], - 'ab_ssl_ca' => ['fk_sca_idx','fk_sca_acc_idx'], - 'ab_static_page' => ['cat','start','expire','name','IDS'], - 'ab_static_page_category' => ['status','name','IDS'], - 'ab_static_page_translate' => ['IDS'], - 'ab_task' => ['fk_tsk_set_idx'], - 'ab_task_log' => ['fk_tl_task'], - 'accounts' => ['ab_account_user_id_foreign','fk_acc_set_idx','fk_acc_lan_idx','fk_acc_rtm_idx','fk_acc_cty_idx','fk_acc_cur_idx'], - 'charges' => ['charges_account_id_site_id_foreign','charges_product_id_site_id_foreign','charges_service_id_site_id_foreign','charges_user_id_site_id_foreign'], - 'countries' => ['countries_currency_id_foreign','name_UNIQUE','two_code_UNIQUE','three_code_UNIQUE'], - 'currencies' => ['three_digit_UNIQUE'], - 'external_account' => ['external_account_external_integration_id_foreign','external_account_account_id_foreign','sae'], - 'external_integrations' => ['external_integrations_user_id_foreign'], - 'languages' => ['name_UNIQUE','iso_UNIQUE'], - 'payment_items' => ['fk_pi_inv_idx','payment_items_payment_id_site_id_foreign','payment_items_site_id_payment_id_invoice_id_unique'], - 'payments' => ['fk_pay_acc_idx','fk_pay_cp_idx','fk_pay_acc_b_idx','payments_site_id_id_unique'], - 'quickbooks_tokens' => ['quickbooks_tokens_user_id_foreign'], - 'service__generic' => ['service__generic_service_id_site_id_foreign','service__generic_product_id_site_id_foreign','service__generic_site_id_service_id_unique'], - 'service_domains' => ['fk_sd_svc_idx','fk_sd_hrp_idx','fk_sd_ht_idx','UNIQUE'], - 'site_details' => ['site_details_site_id_key_unique'], - 'sites' => ['sites_site_id_index','sites_admin_id_site_id_foreign','sites_country_id_foreign','sites_currency_id_foreign','sites_language_id_foreign','sites_site_id_url_unique'], - 'supplier_details' => ['supplier_details_site_id_foreign','supplier_details_supplier_id_site_id_unique'], - 'taxes' => ['UNIQUE'], - 'users' => ['users_site_id_email_unique','users_parent_id_foreign','users_language_id_foreign','users_currency_id_foreign','site_user_id_idx'], - ]; - - Schema::dropIfExists('ab_host_server_id'); - Schema::dropIfExists('ab_host_tld_id'); - DB::statement('ALTER TABLE ab_rtm RENAME TO rtm'); - - foreach ($constraints as $table => $constraint) { - Schema::table($table, function (Blueprint $table) use ($constraint) { - foreach ($constraint as $item) - $table->dropForeign($item); - }); - } - - foreach ($indexes as $table => $constraint) { - Schema::table($table, function (Blueprint $table) use ($constraint) { - foreach ($constraint as $item) - $table->dropIndex($item); - }); - } - - $tables = collect(array_unique(array_merge(array_keys($constraints),array_keys($indexes)))); - $except = [ - 'ab_group','ab_record_id','ab_service__adsl_traffic','accounts','external_account','site_details', - 'ab_account_memo','ab_asset_pool','ab_asset','ab_discount','ab_host_server','ab_import','ab_invoice_item_discount', - 'ab_log_error','ab_setup_invoice','ab_static_page','ab_static_page_category','ab_static_page_translate', - 'ab_email_template', - ]; - - foreach ($tables->diff($except) as $table) { - DB::statement(sprintf('ALTER TABLE %s MODIFY id int unsigned auto_increment',$table)); - - if (Schema::hasColumn($table,'site_id')) { - DB::statement(sprintf('ALTER TABLE %s MODIFY site_id int unsigned NOT NULL',$table)); - } - } - - Schema::table('sites', function (Blueprint $table) { - $table->index(['site_id']); - }); - - foreach ($tables->diff($except)->diff(['sites']) as $table) { - if (Schema::hasColumn($table,'site_id')) { - dump($table); - Schema::table($table, function (Blueprint $table) { - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - $table->index(['id','site_id']); - }); - } - } - - DB::statement('ALTER TABLE currencies RENAME COLUMN iso_code TO iso'); - Schema::table('currencies', function (Blueprint $table) { - $table->unique(['name']); - $table->unique(['iso']); - }); - - Schema::table('languages', function (Blueprint $table) { - $table->unique(['name']); - $table->unique(['iso']); - }); - - DB::statement('ALTER TABLE countries MODIFY currency_id int unsigned'); - Schema::table('countries', function (Blueprint $table) { - $table->foreign(['currency_id'])->references(['id'])->on('currencies'); - $table->index(['id','currency_id']); - $table->unique(['name']); - $table->unique(['two_code']); - $table->unique(['three_code']); - }); - - DB::statement('ALTER TABLE users MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL'); - Schema::table('users', function (Blueprint $table) { - $table->dropColumn(['currency_id']); - $table->foreign(['country_id'])->references(['id'])->on('countries'); - $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['language_id'])->references(['id'])->on('languages'); - }); - - DB::statement('DELETE FROM accounts WHERE id=0'); - DB::statement('ALTER TABLE accounts MODIFY id int unsigned auto_increment'); - DB::statement('ALTER TABLE accounts MODIFY site_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE accounts MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL,MODIFY rtm_id int unsigned DEFAULT NULL,MODIFY active tinyint(1) NOT NULL'); - Schema::table('accounts', function (Blueprint $table) { - $table->dropColumn(['currency_id','language_id']); - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - $table->index(['id','site_id']); - $table->foreign(['country_id'])->references(['id'])->on('countries'); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['rtm_id','site_id'])->references(['id','site_id'])->on('rtm'); - }); - - DB::statement('ALTER TABLE rtm MODIFY account_id int unsigned NOT NULL,MODIFY parent_id int unsigned'); - Schema::table('rtm', function (Blueprint $table) { - $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('rtm'); - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - }); - - DB::statement('ALTER TABLE sites MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL'); - - Schema::table('sites', function (Blueprint $table) { - $table->foreign(['country_id','currency_id'])->references(['id','currency_id'])->on('countries'); - $table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['language_id'])->references(['id'])->on('languages'); - }); - - DB::statement('ALTER TABLE site_details MODIFY site_id int unsigned NOT NULL'); - Schema::table('site_details', function (Blueprint $table) { - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->unique(['site_id','key']); - }); - - DB::statement('ALTER TABLE taxes MODIFY country_id int unsigned NOT NULL'); - Schema::table('taxes', function (Blueprint $table) { - $table->foreign(['country_id'])->references(['id'])->on('countries'); - $table->unique(['country_id','zone']); - }); - } -} \ No newline at end of file diff --git a/database/migrations/2021_12_20_225017_optimize_product.php b/database/migrations/2021_12_20_225017_optimize_product.php deleted file mode 100644 index f1b8e25..0000000 --- a/database/migrations/2021_12_20_225017_optimize_product.php +++ /dev/null @@ -1,632 +0,0 @@ -firstOrNew(); - - Schema::table('ab_product', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->dropIndex(['id','site_id']); - $table->dropIndex('ab_product_site_id_foreign'); - }); - - DB::statement('ALTER TABLE ab_product RENAME TO products'); - - Schema::table('products', function (Blueprint $table) { - $table->dropColumn(['cart_multiple']); - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - }); - - DB::statement('ALTER TABLE suppliers MODIFY address1 varchar(255),MODIFY city varchar(255),MODIFY state varchar(255),MODIFY postcode varchar(255)'); - - Schema::table('supplier_details', function (Blueprint $table) { - $table->jsonb('connections')->nullable(); - }); - - foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_adsl_supplier') as $o) { - switch($o->name) { - case 'PeopleAgent': - $type = 'broadband'; - $name = 'People Telecom'; - break; - - case 'iiNetADSL': - $type = 'broadband'; - $name = 'iiNet'; - break; - - case 'ExetelVisp': - $type = 'broadband'; - $name = 'Exetel'; - break; - - case 'ExetelHSPA': - $type = 'hspa'; - $name = 'Exetel'; - break; - - case 'ExetelPE': - $type = 'ethernet'; - $name = 'Exetel'; - break; - - default: - throw new Exception('Unknown Supplier: '.$o->name); - } - - $so = \App\Models\Supplier::where('name',$name)->singleOrNew(); - $so->name = $name; - $so->active = $so->active ?: $o->active; - $so->save(); - - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('supplier_id',$so->id) - ->where('site_id',$o->site_id) - ->firstOrNew(); - - if (! $sdo->exists) { - $sdo->site_id = $o->site_id; - } - - $connections = $sdo->connections ?: collect(); - - $connections->put($type,[ - 'user'=>$o->stats_username, - 'pass'=>$o->stats_password, - 'last'=>$o->stats_lastupdate, - 'url'=>$o->stats_url, - ]); - - $sdo->connections = $connections; - - $so->detail()->save($sdo); - }; - - Schema::table('ab_adsl_supplier_plan', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->dropIndex(['id','site_id']); - $table->dropIndex('ab_adsl_supplier_plan_site_id_foreign'); - }); - - DB::statement('ALTER TABLE ab_adsl_supplier_plan RENAME TO supplier_broadband'); - DB::statement('ALTER TABLE supplier_broadband MODIFY product_id varchar(16) NOT NULL'); - DB::statement('ALTER TABLE supplier_broadband MODIFY base_cost double NOT NULL'); - DB::statement('ALTER TABLE supplier_broadband MODIFY active tinyint(1)'); - DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN supplier_id TO old_supplier_id'); - DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN offpeak_start TO old_offpeak_start'); - DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN offpeak_end TO old_offpeak_end'); - - Schema::table('supplier_broadband', function (Blueprint $table) { - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - $table->time('offpeak_start')->nullable()->after('old_offpeak_end'); - $table->time('offpeak_end')->nullable()->after('offpeak_start'); - }); - - Schema::table('supplier_broadband', function (Blueprint $table) { - $table->integer('supplier_detail_id')->unsigned()->nullable()->after('old_supplier_id'); - - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - - \Illuminate\Support\Facades\DB::select("UPDATE ab_service SET model='App\\\\Models\\\\Service\\\\Broadband' where model='App\\\\Models\\\\Service\\\\Adsl'"); - \Illuminate\Support\Facades\DB::select("UPDATE products SET model='App\\\\Models\\\\Product\\\\Broadband' where model='App\\\\Models\\\\Product\\\\Adsl'"); - - // Convert to use the new supplier - foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_adsl_supplier') as $o) { - switch ($o->name) { - case 'PeopleAgent': - $so = \App\Models\Supplier::where('name','People Telecom')->singleOrFail(); - break; - - case 'iiNetADSL': - $so = \App\Models\Supplier::where('name','iiNet')->singleOrFail(); - break; - - case 'ExetelVisp': - case 'ExetelHSPA': - case 'ExetelPE': - $so = \App\Models\Supplier::where('name','Exetel')->singleOrFail(); - break; - - default: - throw new Exception('Unknown Supplier: ' . $o->name); - } - - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('supplier_id',$so->id) - ->where('site_id',$o->site_id) - ->singleOrFail(); - - \Illuminate\Support\Facades\DB::select(sprintf("UPDATE supplier_broadband SET supplier_detail_id=%d where old_supplier_id=%d and site_id=%d",$sdo->id,$o->id,$sdo->site_id)); - } - - // Convert out dates - foreach (\App\Models\Supplier\Broadband::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->old_offpeak_start) - $o->offpeak_start = \Carbon\Carbon::createFromTimestamp($o->old_offpeak_start); - if ($o->old_offpeak_end) - $o->offpeak_end = \Carbon\Carbon::createFromTimestamp($o->old_offpeak_end); - $o->save(); - } - - Schema::table('supplier_broadband', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropColumn(['date_orig','date_last','old_supplier_id','old_offpeak_start','old_offpeak_end']); - }); - Schema::dropIfExists('ab_adsl_supplier'); - - DB::statement('ALTER TABLE supplier_broadband MODIFY extra_charged tinyint(1)'); - DB::statement('ALTER TABLE supplier_broadband MODIFY extra_shaped tinyint(1)'); - DB::statement('ALTER TABLE supplier_broadband MODIFY contract_term int unsigned'); - - Schema::table('ab_adsl_plan', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->dropIndex(['id','site_id']); - $table->dropIndex('ab_adsl_plan_site_id_foreign'); - }); - - DB::statement('ALTER TABLE ab_adsl_plan RENAME TO product_broadband'); - DB::statement('ALTER TABLE product_broadband DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)'); - DB::statement('ALTER TABLE product_broadband MODIFY extra_charged tinyint(1)'); - DB::statement('ALTER TABLE product_broadband MODIFY extra_shaped tinyint(1)'); - DB::statement('ALTER TABLE product_broadband MODIFY contract_term int unsigned'); - DB::statement('ALTER TABLE product_broadband RENAME COLUMN adsl_supplier_plan_id TO supplier_broadband_id'); - DB::statement('ALTER TABLE product_broadband MODIFY supplier_broadband_id int unsigned'); - - Schema::table('product_broadband', function (Blueprint $table) { - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); - $table->dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - }); - - // Convert product pricegroups - foreach (\App\Models\Product::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $po) { - if ($po->date_orig) - $po->created_at = \Carbon\Carbon::createFromTimestamp($po->date_orig); - if ($po->date_last) - $po->updated_at = \Carbon\Carbon::createFromTimestamp($po->date_last); - - if (! ($po instanceof \Illuminate\Support\Collection) || ! $po->price_group->count()) { - $original = $po->getRawOriginal('price_group'); - - // serialized - if (preg_match('/^a:/',$original)) { - try { - $price_group = collect(unserialize(str_replace("\n","",$original))); - } catch (Exception $e) { - dd(['error'=>$e->getMessage(),'raw'=>$po->getRawOriginal('price_group')]); - } - - } elseif (is_null($po->getRawOriginal('price_group'))) { - $price_group = collect(); - - } else { - try { - $price_group = unserialize(gzuncompress($po->getRawOriginal('price_group'))); - } catch (Exception $e) { - dd(['error'=>$e->getMessage(),'raw'=>$po->getRawOriginal('price_group')]); - } - } - - $new_price_group = collect(); - - // Remove any blank entries, or when base/setup = 0 - foreach ($price_group as $group => $values) { - $build = collect(); - - foreach ($values as $key => $pricing) { - switch ($key) { - case 'show': - $build->put('show',(bool) $pricing); - break; - - default: - // key is a time period - if ((! Arr::get($pricing,'price_base')) && (! Arr::get($pricing,'price_setup'))) - break; - - $build->put($key,[ - 'base'=>Arr::get($pricing,'price_base'), - 'setup'=>Arr::get($pricing,'price_setup'), - ]); - } - } - - $new_price_group->put($group,$build); - } - - $po->price_group = $new_price_group; - } - - $po->save(); - } - - DB::statement('ALTER TABLE products MODIFY taxable tinyint(1),MODIFY active tinyint(1),MODIFY price_recurr_strict tinyint(1),MODIFY prod_plugin_data int unsigned'); - DB::statement('ALTER TABLE products RENAME COLUMN price_group TO pricing'); - DB::statement('ALTER TABLE products RENAME COLUMN price_recurr_default TO price_recur_default'); - DB::statement('ALTER TABLE products RENAME COLUMN price_recurr_strict TO price_recur_strict'); - DB::statement('ALTER TABLE products RENAME COLUMN prod_plugin_data TO model_id'); - Schema::table('products', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','group_avail','avail_category','price_recurr_day','price_recurr_weekday','prod_plugin_file']); - }); - Schema::dropIfExists('ab_voip_plan'); - - Schema::create('tlds',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->string('name',64)->unique(); - }); - - Schema::create('supplier_domain',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id',16); - $table->string('product_desc',128)->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->unsigned()->nullable(); - $table->integer('tld_id')->unsigned(); - $table->text('whois_url')->nullable(); - $table->text('config')->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['tld_id'])->references(['id'])->on('tlds'); - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - Schema::create('supplier_host',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id',16); - $table->string('product_desc',128)->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - Schema::create('supplier_ssl',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id',16); - $table->string('product_desc',128)->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - Schema::create('supplier_generic',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id',16); - $table->string('product_desc',128)->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - Schema::create('supplier_voip',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id',16); - $table->string('product_desc',128)->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - }); - - Schema::create('product_domain',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->integer('supplier_domain_id')->unsigned(); - $table->string('name',64); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_domain_id','site_id'])->references(['id','site_id'])->on('supplier_domain'); - }); - Schema::create('product_host',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->integer('supplier_host_id')->unsigned(); - $table->string('name',64); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_host_id','site_id'])->references(['id','site_id'])->on('supplier_host'); - }); - Schema::create('product_ssl',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->integer('supplier_ssl_id')->unsigned(); - $table->string('name',64); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_ssl_id','site_id'])->references(['id','site_id'])->on('supplier_ssl'); - }); - Schema::create('product_generic',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->integer('supplier_generic_id')->unsigned(); - $table->string('name',64); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_generic_id','site_id'])->references(['id','site_id'])->on('supplier_generic'); - }); - Schema::create('product_voip',function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->integer('supplier_voip_id')->unsigned(); - $table->string('name',64); - $table->integer('contract_term')->unsigned()->nullable(); - - $table->index(['id','site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_voip_id','site_id'])->references(['id','site_id'])->on('supplier_voip'); - }); - - // Setup Domains - foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_domain_tld') as $o) { - $oo = new \App\Models\TLD; - - if ($o->date_orig) - $oo->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $oo->created_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - - $oo->name = strtolower($o->name); - $oo->save(); - }; - - foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_domain_registrar') as $o) { - $so = \App\Models\Supplier::where('name',$o->name)->singleOrNew(); - $so->name = $o->name; - $so->active = $so->active ?: $o->active; - $so->save(); - - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('supplier_id',$so->id) - ->where('site_id',1) - ->firstOrNew(); - - $sdo->site_id = 1; - $connects = collect(); - if ($o->whitelabel_url) - $connects->put('whitelabel_url',$o->whitelabel_url); - if ($o->manage_url) - $connects->put('manage_url',$o->manage_url); - - $sdo->connections = $connects; - $so->detail()->save($sdo); - - foreach (\App\Models\TLD::cursor() as $tldo) { - $sd = \App\Models\Supplier\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('tld_id',$tldo->id) - ->where('site_id',$sdo->site_id) - ->where('supplier_detail_id',$sdo->id) - ->firstOrNew(); - - $sd->supplier_detail_id = $sdo->id; - $sd->tld_id = $tldo->id; - $sd->site_id = $sdo->site_id; - $sd->active = TRUE; - $sd->product_id = 'Domain Name'; - $sd->product_desc = 'Domain Name License'; - $sd->base_cost = '.01'; - $sd->contract_term = 12; - - $sd->save(); - - $pd = \App\Models\Product\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('site_id',$sdo->site_id) - ->where('supplier_domain_id',$sd->id) - ->firstOrNew(); - - $pd->supplier_domain_id = $sd->id; - $pd->site_id = $sd->site_id; - $pd->name = $sd->name; - - $pd->save(); - } - } - - // No need to update tables, if we dont have a site setup yet. - if (! $site->exists) - return; - - // SSL - $so = \App\Models\Supplier::where('name','Graytech Hosting Pty Ltd')->firstOrNew(); - $so->name = 'Graytech Hosting Pty Ltd'; - $so->active = TRUE; - $so->save(); - - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('site_id','1') - ->where('supplier_id',$so->id) - ->firstOrNew(); - $sdo->site_id = $site->site_id; - $so->detail()->save($sdo); - - $o = new \App\Models\Supplier\SSL; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'Graytech SSL'; - $o->base_cost = 0; - $o->setup_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\SSL; - $oo->site_id = $sdo->site_id; - $oo->supplier_ssl_id = $o->id; - $oo->name = 'Graytech SSL'; - $oo->save(); - - $o = new \App\Models\Supplier\Host; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'Graytech Hosting'; - $o->base_cost = 0; - $o->setup_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\Host; - $oo->site_id = $sdo->site_id; - $oo->supplier_host_id = $o->id; - $oo->name = 'Graytech Hosting'; - $oo->save(); - - $so = \App\Models\Supplier::where('name','crazydomain')->firstOrFail(); - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('site_id','1') - ->where('supplier_id',$so->id) - ->firstOrNew(); - $sdo->site_id = $site->site_id; - $so->detail()->save($sdo); - - $o = new \App\Models\Supplier\Host; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'CD Host'; - $o->base_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\Host; - $oo->site_id = $sdo->site_id; - $oo->supplier_host_id = $o->id; - $oo->name = 'Crazy Domains Hosting'; - $oo->save(); - - // VOIP - $so = \App\Models\Supplier::where('name','Exetel')->firstOrFail(); - $sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class) - ->where('site_id','1') - ->where('supplier_id',$so->id) - ->firstOrNew(); - $sdo->site_id = $site->site_id; - $so->detail()->save($sdo); - - $o = new \App\Models\Supplier\Phone; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'VOIP $10'; - $o->base_cost = 9.09; - $o->setup_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\Phone; - $oo->site_id = $sdo->site_id; - $oo->supplier_voip_id = $o->id; - $oo->name = 'VOIP $10'; - $oo->save(); - - $o = new \App\Models\Supplier\Phone; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'VOIP'; - $o->base_cost = 0; - $o->setup_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\Phone; - $oo->site_id = $sdo->site_id; - $oo->supplier_voip_id = $o->id; - $oo->name = 'VOIP'; - $oo->save(); - - $o = new \App\Models\Supplier\Phone; - $o->site_id = $sdo->site_id; - $o->active = TRUE; - $o->product_id = 'VOIP B-100'; - $o->product_desc = 'VOIP Business 100 Lines'; - $o->base_cost = 22.727; - $o->setup_cost = 0; - $o->supplier_detail_id = $sdo->id; - $o->save(); - - $oo = new \App\Models\Product\Phone; - $oo->site_id = $sdo->site_id; - $oo->supplier_voip_id = $o->id; - $oo->name = 'VOIP B-10'; - $oo->save(); - - // Manually run this, since we havent worked out site_id when running migrate. - // update products set model_id=49,model='App\\Models\\Product\\Domain' where id=78; - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -} diff --git a/database/migrations/2022_04_02_092021_email_supplier.php b/database/migrations/2022_04_02_092021_email_supplier.php deleted file mode 100644 index 8850d13..0000000 --- a/database/migrations/2022_04_02_092021_email_supplier.php +++ /dev/null @@ -1,106 +0,0 @@ -integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_detail_id')->unsigned(); - $table->string('product_id'); - $table->string('product_desc')->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->nullable(); - - $table->foreign(['supplier_detail_id'])->references(['id'])->on('supplier_details'); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - - Schema::create('product_email', function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->boolean('active'); - $table->integer('supplier_email_id')->unsigned(); - $table->string('product_id'); - $table->string('product_desc')->nullable(); - $table->float('base_cost'); - $table->float('setup_cost')->nullable(); - $table->integer('contract_term')->nullable(); - - $table->foreign(['supplier_email_id'])->references(['id'])->on('supplier_email'); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - - Schema::create('service_emails', function (Blueprint $table) { - $table->integer('id',TRUE)->unsigned(); - $table->integer('site_id')->unsigned(); - $table->integer('service_id')->unsigned(); - - $table->integer('tld_id')->unsigned(); - $table->string('domain_name',128); - $table->date('expire_at')->nullable(); - $table->string('admin_url')->nullable(); - $table->string('admin_user')->nullable(); - $table->string('admin_pass')->nullable(); - $table->integer('accounts')->nullable(); - - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['service_id'])->references(['id'])->on('ab_service'); - $table->foreign(['tld_id'])->references(['id'])->on('tlds'); - }); - - // Migrate email hosting from hosting table to service_email - // Setup Domains - foreach (\Illuminate\Support\Facades\DB::select("SELECT * FROM ab_service__hosting WHERE host_type='email'") as $o) { - $oo = new \App\Models\Service\Email; - - foreach (['site_id','service_id'] as $item) - $oo->{$item} = $o->{$item}; - - $oo->tld_id = $o->domain_tld_id; - $oo->domain_name = strtolower($o->domain_name); - $oo->admin_user = strtolower($o->host_username); - $oo->admin_pass = $o->host_password; - $oo->expire_at = \Carbon\Carbon::createFromTimestamp($o->host_expire); - $oo->save(); - - \App\Models\Service::where('id',$o->service_id)->update(['model'=>get_class($oo)]); - }; - - \Illuminate\Support\Facades\DB::select("DELETE FROM ab_service__hosting WHERE host_type='email'"); - - // insert into suppliers value (null,1,'Google',null,null,null,null,null); - // insert into supplier_details values (null,now(),now(),null,null,null,null,14,1,null); - // insert into supplier_email values (null,now(),now(),1,1,13,'Legacy Email','Legacy Email',0,0,0); - // insert into product_email values (null,now(),now(),1,1,1,'Email Hosting',null,150,0,12); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - /* - Schema::dropIfExists('product_email'); - Schema::dropIfExists('supplier_email'); - Schema::dropIfExists('service_emails'); - */ - abort(500,'cant go back'); - } -} diff --git a/database/migrations/2022_04_19_121452_rename_service_tables.php b/database/migrations/2022_04_19_121452_rename_service_tables.php deleted file mode 100644 index e88c1b6..0000000 --- a/database/migrations/2022_04_19_121452_rename_service_tables.php +++ /dev/null @@ -1,345 +0,0 @@ -dropPrimary(); - $table->dropForeign('ab_service_site_id_foreign'); - $table->primary(['id','site_id']); - $table->dropIndex('ab_service_site_id_foreign'); - $table->dropIndex('ab_service_id_site_id_index'); - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->date('invoice_last_at')->nullable()->after('date_last_invoice'); - $table->date('invoice_next_at')->nullable()->after('date_next_invoice'); - $table->date('start_at')->nullable()->after('date_start'); - $table->date('stop_at')->nullable()->after('date_end'); - }); - - DB::statement('ALTER TABLE ab_service RENAME TO services'); - DB::statement('ALTER TABLE services MODIFY account_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE services MODIFY account_billing_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE services MODIFY product_id int unsigned NOT NULL'); - DB::statement('UPDATE services SET taxable=1'); - DB::statement('UPDATE services SET active=0 WHERE active IS NULL'); - DB::statement('ALTER TABLE services MODIFY active tinyint(1) NOT NULL,MODIFY suspend_billing tinyint(1) DEFAULT NULL,MODIFY external_billing tinyint(1) DEFAULT NULL,MODIFY taxable tinyint(1) DEFAULT NULL'); - DB::statement('ALTER TABLE services RENAME COLUMN orderby_id TO ordered_by'); - DB::statement('ALTER TABLE services MODIFY ordered_by int unsigned'); - - // Convert out dates - foreach (\App\Models\Service::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->date_last_invoice) - $o->invoice_last_at = \Carbon\Carbon::createFromTimestamp($o->date_last_invoice); - if ($o->date_next_invoice) - $o->invoice_next_at = \Carbon\Carbon::createFromTimestamp($o->date_next_invoice); - if ($o->date_start) - $o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start); - if ($o->date_end) - $o->stop_at = \Carbon\Carbon::createFromTimestamp($o->date_end); - $o->save(); - } - - Schema::table('services', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','date_last_invoice','date_next_invoice','date_start','date_end','queue','price_group']); - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - $table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - }); - - DB::statement('ALTER TABLE service_domains RENAME TO service_domain'); - DB::statement('ALTER TABLE service_emails RENAME TO service_email'); - - Schema::table('ab_service_change', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('ab_service_change_site_id_foreign'); - $table->dropIndex('ab_service_change_site_id_foreign'); - $table->dropIndex('ab_service_change_id_site_id_index'); - }); - - DB::statement('ALTER TABLE ab_service_change RENAME TO service__change'); - DB::statement('ALTER TABLE service__change MODIFY service_id int unsigned'); - DB::statement('ALTER TABLE service__change MODIFY product_id int unsigned'); - DB::statement('ALTER TABLE service__change MODIFY ordered_by int unsigned'); - - Schema::table('service__change', function (Blueprint $table) { - $table->date('ordered_at')->nullable()->after('ordered_by'); - $table->date('effective_at')->nullable()->after('ordered_at'); - - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users'); - }); - - // Convert out dates - foreach (\App\Models\ServiceChange::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_ordered) - $o->ordered_at = \Carbon\Carbon::createFromTimestamp($o->date_ordered); - if ($o->date_effective) - $o->effective_at = \Carbon\Carbon::createFromTimestamp($o->date_effective); - $o->save(); - } - - DB::statement('ALTER TABLE service__change MODIFY ordered_at int unsigned NOT NULL'); - DB::statement('ALTER TABLE service__change MODIFY effective_at int unsigned NOT NULL'); - - Schema::table('service__change', function (Blueprint $table) { - $table->dropColumn(['date_ordered','date_effective']); - }); - - DB::statement('ALTER TABLE service__generic MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service__generic MODIFY product_id int unsigned DEFAULT NULL'); - DB::statement('UPDATE service__generic SET product_id=NULL WHERE product_id=0'); - Schema::table('service__generic', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('service__generic_site_id_foreign'); - $table->dropIndex('service__generic_site_id_foreign'); - $table->dropIndex('service__generic_id_site_id_index'); - - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - }); - - DB::statement('ALTER TABLE service_domain MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_domain MODIFY domain_tld_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_domain MODIFY domain_registrar_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE service_domain MODIFY domain_name varchar(128) NOT NULL'); - DB::statement('ALTER TABLE service_domain RENAME COLUMN domain_tld_id TO tld_id'); - - Schema::table('service_domain', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('service_domains_site_id_foreign'); - $table->dropIndex('service_domains_site_id_foreign'); - $table->dropIndex('service_domains_id_site_id_index'); - - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['tld_id'])->references(['id'])->on('tlds'); - - $table->date('expire_at')->nullable()->after('domain_expire'); - }); - - // Convert out dates - foreach (\App\Models\Service\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->domain_expire) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->domain_expire); - $o->save(); - } - - Schema::table('service_domain', function (Blueprint $table) { - $table->dropColumn(['registrar_lastsync','domain_expire']); - }); - - DB::statement('ALTER TABLE service_email DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)'); - - Schema::table('service_email', function (Blueprint $table) { - $table->unique(['domain_name','tld_id']); - $table->dropForeign('service_emails_site_id_foreign'); - $table->dropForeign('service_emails_service_id_foreign'); - $table->dropForeign('service_emails_tld_id_foreign'); - - $table->foreign(['tld_id'])->references(['id'])->on('tlds'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - }); - - DB::statement('ALTER TABLE ab_service__hosting RENAME TO service_host'); - DB::statement('ALTER TABLE service_host RENAME COLUMN domain_tld_id TO tld_id'); - DB::statement('ALTER TABLE service_host MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_host MODIFY tld_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_host MODIFY host_server_id int unsigned DEFAULT NULL'); - - DB::statement('ALTER TABLE service_host MODIFY domain_name varchar(128) NOT NULL'); - - Schema::table('service_host', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('ab_service__hosting_site_id_foreign'); - $table->dropIndex('ab_service__hosting_site_id_foreign'); - $table->dropIndex('ab_service__hosting_id_site_id_index'); - - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['tld_id'])->references(['id'])->on('tlds'); - - $table->date('expire_at')->nullable()->after('host_expire'); - }); - - // Convert our dates - foreach (\App\Models\Service\Host::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->server_data && (strlen($o->server_data) > 8) && gzuncompress($o->server_data)) - $o->server_data = NULL; - if ($o->host_expire) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->host_expire); - $o->save(); - } - - Schema::table('service_host', function (Blueprint $table) { - $table->dropColumn(['host_expire','server_data_date']); - }); - - DB::statement('ALTER TABLE product_broadband RENAME COLUMN supplier_broadband_id TO supplier_item_id'); - DB::statement('ALTER TABLE product_domain RENAME COLUMN supplier_domain_id TO supplier_item_id'); - DB::statement('ALTER TABLE product_email RENAME COLUMN supplier_email_id TO supplier_item_id'); - DB::statement('ALTER TABLE product_host RENAME COLUMN supplier_host_id TO supplier_item_id'); - DB::statement('ALTER TABLE product_ssl RENAME COLUMN supplier_ssl_id TO supplier_item_id'); - DB::statement('ALTER TABLE product_generic RENAME COLUMN supplier_generic_id TO supplier_item_id'); - - DB::statement('ALTER TABLE product_voip RENAME TO product_phone'); - DB::statement('ALTER TABLE product_phone RENAME COLUMN supplier_voip_id TO supplier_item_id'); - - Schema::table('product_phone', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('product_voip_supplier_voip_id_site_id_foreign'); - $table->dropForeign('product_voip_site_id_foreign'); - $table->dropIndex('product_voip_supplier_voip_id_site_id_foreign'); - $table->dropIndex('product_voip_site_id_foreign'); - $table->dropIndex('product_voip_id_site_id_index'); - }); - - DB::statement('ALTER TABLE supplier_voip RENAME TO supplier_phone'); - Schema::table('supplier_phone', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->dropForeign('supplier_voip_supplier_detail_id_site_id_foreign'); - $table->dropForeign('supplier_voip_site_id_foreign'); - $table->dropIndex('supplier_voip_id_site_id_index'); - - $table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details'); - - $table->string('technology')->nullable(); - }); - - Schema::table('product_phone', function (Blueprint $table) { - $table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_phone'); - - $table->string('technology')->nullable(); - }); - - DB::statement('ALTER TABLE ab_service__voip RENAME TO service_phone'); - DB::statement('ALTER TABLE service_phone MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_phone MODIFY service_number varchar(10) NOT NULL'); - DB::statement('ALTER TABLE service_phone MODIFY site_id int unsigned NOT NULL'); - - Schema::table('service_phone', function (Blueprint $table) { - $table->primary(['id','site_id']); - $table->date('connect_at')->nullable()->after('contract_term'); - $table->date('expire_at')->nullable()->after('connect_at'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->string('technology')->nullable(); - }); - - DB::statement('ALTER TABLE service_phone MODIFY id int unsigned auto_increment'); - - // Convert our dates - foreach (\App\Models\Service\Phone::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->service_connect_date) - $o->connect_at = \Carbon\Carbon::createFromTimestamp($o->service_connect_date); - if ($o->getRawOriginal('contract_term') === 0) - $o->contract_term = NULL; - if ($o->service_contract_date && $o->getRawOriginal('contract_term')) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->service_contract_date)->addMonths($o->getRawOriginal('contract_term')); - $o->save(); - } - - Schema::table('service_phone', function (Blueprint $table) { - $table->dropColumn(['service_connect_date','service_contract_date','contract_term']); - }); - - DB::statement('ALTER TABLE ab_service__adsl RENAME TO service_broadband'); - DB::statement('ALTER TABLE service_broadband MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_broadband MODIFY service_stats_collect tinyint(1) DEFAULT NULL'); - DB::statement('ALTER TABLE service_broadband RENAME COLUMN service_stats_lastupdate TO service_stats_at'); - DB::statement('ALTER TABLE service_broadband RENAME COLUMN provided_adsl_plan_id TO provided_supplier_broadband_id'); - DB::statement('ALTER TABLE service_broadband MODIFY provided_supplier_broadband_id int unsigned DEFAULT NULL'); - // @todo drop column provided_adsl_plan_id - - Schema::table('service_broadband', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - $table->date('connect_at')->nullable()->after('contract_term'); - $table->date('expire_at')->nullable()->after('connect_at'); - $table->ipAddress('ip6address')->nullable()->after('ipaddress'); - $table->string('technology')->nullable(); - - $table->dropForeign('ab_service__adsl_site_id_foreign'); - $table->dropIndex('ab_service__adsl_site_id_foreign'); - $table->dropIndex('ab_service__adsl_id_site_id_index'); - - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['provided_supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); - }); - - // Convert our dates - foreach (\App\Models\Service\Broadband::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->service_connect_date) - $o->connect_at = \Carbon\Carbon::createFromTimestamp($o->service_connect_date); - if ($o->getRawOriginal('contract_term') === 0) - $o->contract_term = NULL; - if ($o->service_contract_date && $o->getRawOriginal('contract_term')) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->service_contract_date)->addMonths($o->getRawOriginal('contract_term')); - $o->save(); - } - - Schema::table('service_broadband', function (Blueprint $table) { - $table->dropColumn(['service_connect_date','service_contract_date','contract_term']); - }); - - Schema::table('supplier_broadband', function (Blueprint $table) { - $table->string('technology')->nullable(); - }); - - DB::select("UPDATE services SET model='App\\\\Models\\\\Service\\\\Phone' where model='App\\\\Models\\\\Service\\\\Voip'"); - DB::select("UPDATE products SET model='App\\\\Models\\\\Product\\\\Phone' where model='App\\\\Models\\\\Product\\\\Voip'"); - - DB::statement('ALTER TABLE ab_service__ssl RENAME TO service_ssl'); - DB::statement('ALTER TABLE service_ssl MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service_ssl MODIFY ssl_ca_id int unsigned DEFAULT NULL'); - - Schema::table('service_ssl', function (Blueprint $table) { - $table->dropPrimary(); - $table->primary(['id','site_id']); - - $table->dropForeign('ab_service__ssl_site_id_foreign'); - $table->dropIndex('ab_service__ssl_site_id_foreign'); - $table->dropIndex('ab_service__ssl_id_site_id_index'); - - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - }); - - foreach (DB::select('SELECT * FROM products where model="App\\\\Models\\\\Product\\\\SSL"') as $o) { - DB::select('UPDATE services set model="App\\\\Models\\\\Service\\\\SSL" WHERE product_id='.$o->id); - }; - - Schema::table('products', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -} diff --git a/database/migrations/2022_04_20_134953_rename_traffic.php b/database/migrations/2022_04_20_134953_rename_traffic.php deleted file mode 100644 index 0ca84b3..0000000 --- a/database/migrations/2022_04_20_134953_rename_traffic.php +++ /dev/null @@ -1,42 +0,0 @@ -unique(['service_item_id','site_id','date','time']); - $table->foreign(['service_item_id','site_id'])->references(['id','site_id'])->on('service_broadband'); - $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); - }); - - Schema::table('suppliers', function (Blueprint $table) { - $table->date('usage_last')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -} diff --git a/database/migrations/2022_04_20_183016_updates_to_accounts.php b/database/migrations/2022_04_20_183016_updates_to_accounts.php deleted file mode 100644 index a3faecc..0000000 --- a/database/migrations/2022_04_20_183016_updates_to_accounts.php +++ /dev/null @@ -1,48 +0,0 @@ -datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->date('expire_at')->nullable()->after('updated_at'); - }); - - // Convert our dates - foreach (\App\Models\Account::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->date_expire) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire); - - $o->save(); - } - - Schema::table('accounts', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','date_expire']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2022_04_22_122640_rename_invoice_tables.php b/database/migrations/2022_04_22_122640_rename_invoice_tables.php deleted file mode 100644 index 8f0ab53..0000000 --- a/database/migrations/2022_04_22_122640_rename_invoice_tables.php +++ /dev/null @@ -1,124 +0,0 @@ -dropPrimary(); - $table->dropForeign('ab_invoice_site_id_foreign'); - $table->dropIndex('ab_invoice_site_id_foreign'); - $table->primary(['id','site_id']); - $table->dropIndex('ab_invoice_id_site_id_index'); - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->date('due_at')->nullable()->after('discount_amt'); - }); - - // Convert out dates - foreach (\App\Models\Invoice::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->getRawOriginal('due_date')) - $o->due_at = \Carbon\Carbon::createFromTimestamp($o->getRawOriginal('due_date')); - if ($o->reminders) { - try { - $reminders = unserialize($o->reminders); - } catch (Exception $e) { - $reminders = unserialize(gzuncompress($o->reminders)); - } - - $o->reminders = $reminders; - } - $o->save(); - } - - Schema::table('invoices', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','due_date']); - - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - }); - - DB::statement('ALTER TABLE ab_invoice_item RENAME TO invoice_items'); - DB::statement('ALTER TABLE invoice_items MODIFY invoice_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE invoice_items MODIFY service_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE invoice_items MODIFY product_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE invoice_items MODIFY module_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE invoice_items MODIFY module_ref int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE invoice_items RENAME COLUMN recurring_schedule TO recur_schedule'); - - Schema::table('invoice_items', function (Blueprint $table) { - $table->dropPrimary(); - $table->dropForeign('ab_invoice_item_site_id_foreign'); - $table->dropIndex('ab_invoice_item_site_id_foreign'); - $table->primary(['id','site_id']); - $table->dropIndex('ab_invoice_item_id_site_id_index'); - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->date('start_at')->nullable()->after('recur_schedule'); - $table->date('stop_at')->nullable()->after('start_at'); - }); - - // Convert out dates - foreach (\App\Models\InvoiceItem::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->date_start) - $o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start); - if ($o->date_stop) - $o->stop_at = \Carbon\Carbon::createFromTimestamp($o->date_stop); - $o->save(); - } - - Schema::table('invoice_items', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','date_start','date_stop']); - - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices'); - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - }); - - DB::statement('ALTER TABLE ab_invoice_item_tax RENAME TO invoice_item_taxes'); - DB::statement('ALTER TABLE invoice_item_taxes MODIFY invoice_item_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE invoice_item_taxes MODIFY tax_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE invoice_item_taxes DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)'); - - Schema::table('invoice_item_taxes', function (Blueprint $table) { - $table->dropForeign('ab_invoice_item_tax_site_id_foreign'); - $table->dropIndex('ab_invoice_item_tax_site_id_foreign'); - $table->dropIndex('ab_invoice_item_tax_id_site_id_index'); - $table->dropColumn(['date_orig']); - - $table->foreign(['invoice_item_id','site_id'])->references(['id','site_id'])->on('invoice_items'); - $table->foreign(['tax_id'])->references(['id'])->on('taxes'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2022_04_22_144438_optimise_payments.php b/database/migrations/2022_04_22_144438_optimise_payments.php deleted file mode 100644 index 9b7a8c9..0000000 --- a/database/migrations/2022_04_22_144438_optimise_payments.php +++ /dev/null @@ -1,71 +0,0 @@ -dropForeign(['site_id']); - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->boolean('active')->nullable()->after('updated_at'); - $table->date('paid_at')->nullable()->after('payment_date'); - - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - $table->foreign(['source_id','site_id'])->references(['id','site_id'])->on('users'); - }); - - // Convert out dates - foreach (\App\Models\Payment::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->payment_date) - $o->paid_at = \Carbon\Carbon::createFromTimestamp($o->payment_date); - $o->save(); - } - - Schema::table('payments', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','payment_date']); - }); - - DB::statement('ALTER TABLE payment_items MODIFY payment_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE payment_items MODIFY invoice_id int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE payment_items RENAME COLUMN alloc_amt TO amount'); - - Schema::table('payment_items', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->boolean('active')->nullable()->after('site_id'); - $table->dropColumn(['date_orig','date_last']); - - $table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments'); - }); - - DB::statement('UPDATE payment_items SET active=1'); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2022_06_10_164250_update_charges.php b/database/migrations/2022_06_10_164250_update_charges.php deleted file mode 100644 index dfb313b..0000000 --- a/database/migrations/2022_06_10_164250_update_charges.php +++ /dev/null @@ -1,435 +0,0 @@ -datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - $table->date('start_at')->nullable(); - $table->date('stop_at')->nullable(); - $table->date('charge_at')->nullable(); - }); - - // Convert out dates - foreach (\App\Models\Charge::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - // If we are running again - if ($o->created_at) - continue; - - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->charge_date) - $o->charge_at = \Carbon\Carbon::createFromTimestamp($o->charge_date); - - if ($o->getRawOriginal('attributes')) { - Config::set('site',$o->site); - - // Uncompress if it is - try { - $attributes = gzuncompress($o->getRawOriginal('attributes')); - - // Already uncompressed - } catch (Exception $e) { - $attributes = $o->getRawOriginal('attributes'); - } - - if (str_starts_with($attributes,'a:')) { - $attributes = join("\n", unserialize($attributes)); - } elseif (str_starts_with($attributes,'s:')) { - $attributes = unserialize($attributes); - } - - $attributes = array_filter(explode("\n",str_replace("\r",'',$attributes))); - - /* - $newattrs =[]; - foreach ($attributes as $attr) { - if (str_starts_with($attr,'Period Start==')) { - $date = str_replace('Period Start==', '', $attr); - $o->start_at = \Carbon\Carbon::createFromFormat('d-M-Y', $date); - - } elseif (str_starts_with($attr,'Period From:')) { - $date = str_replace('Period From:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Period End==')) { - $date = str_replace('Period End==','',$attr); - $o->stop_at = \Carbon\Carbon::createFromFormat('d-M-Y',$date); - - } elseif (str_starts_with($attr,'Period To:')) { - $date = str_replace('Period To:','',$attr); - $o->stop_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Connect Date: ')) { - $date = str_replace('Connect Date: ','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Connect:')) { - $date = str_replace('Connect:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Effective==')) { - $date = str_replace('Effective==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('d-M-Y',$date); - - } elseif (str_starts_with($attr,'Effective: ')) { - $date = str_replace('Effective: ','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Effective:')) { - $date = str_replace('Effective:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'Start:')) { - $date = str_replace('Start:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr,'End:')) { - $date = str_replace('End:','',$attr); - $o->stop_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Service Upgraded==')) { - $string = str_replace('Service Upgraded==','',$attr); - array_push($newattrs,['upgrade_to'=>$string]); - dump([$o->id=>sprintf('Removing description: [%s] with (Service Upgrade)',$o->description)]); - $o->description = 'Service Upgrade'; - if ($o->type == 126) - $o->type = 7; - - } elseif (str_starts_with($attr, 'Upgrade From==')) { - $string = str_replace('Upgrade From==','',$attr); - array_push($newattrs,['upgrade_from'=>$string]); - if ($o->type == 126) - $o->type = 7; - - } elseif (str_starts_with($attr, 'Upgrade To==')) { - $string = str_replace('Upgrade To==','',$attr); - array_push($newattrs,['upgrade_to'=>$string]); - dump([$o->id=>sprintf('Removing description: [%s] with (Service Upgrade)',$o->description)]); - $o->description = 'Service Upgrade'; - if ($o->type == 126) - $o->type = 7; - - } elseif (str_starts_with($attr, 'Service Terminated==')) { - $date = str_replace('Service Terminated==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('d-M-Y',$date); - - } elseif (str_starts_with($attr, 'Contact Date=')) { - $date = str_replace('Contact Date=','',$attr); - $o->stop_at = \Carbon\Carbon::createFromFormat('d-M-Y',$date); - if ($o->description == 'ADSL Service Cancellation In Con') - $o->description = 'Service Terminated In Contract'; - if ($o->type == 126) - $o->type = 6; - - } elseif (str_starts_with($attr, 'Actual Cancel:')) { - $date = str_replace('Actual Cancel:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Contact to:')) { - $date = str_replace('Contact to:','',$attr); - $o->stop_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - if ($o->description == 'ADSL Contract Cancellation') - $o->description = 'Service Terminated In Contract'; - if ($o->type == 126) - $o->type = 6; - - } elseif (str_starts_with($attr, 'Service Number=')) { - $string = str_replace('Service Number=','',$attr); - if (! str_replace(' ','',$string) == $o->service->name_short) - dd(['number'=>str_replace(' ','',$string),'service'=>$o->service->name_short]); - - } elseif (str_starts_with($attr, 'Service==')) { - $string = str_replace('Service==','',$attr); - if (! str_replace(' ','',$string) == $o->service->name_short) - dd(['number'=>str_replace(' ','',$string),'service'=>$o->service->name_short]); - - } elseif (str_starts_with($attr, 'ADSL Service==')) { - $string = str_replace('ADSL Service==','',$attr); - if (! str_replace(' ','',$string) == $o->service->name_short) - dd(['number'=>str_replace(' ','',$string),'service'=>$o->service->name_short]); - - } elseif (str_starts_with($attr, 'Service:')) { - $string = str_replace('Service','',$attr); - if (! str_replace(' ','',$string) == $o->service->name_short) - dd(['number'=>str_replace(' ','',$string),'service'=>$o->service->name_short]); - - } elseif (str_starts_with($attr, 'Traffic==')) { - $string = str_replace('Traffic==','',$attr); - array_push($newattrs,['traffic'=>$string]); - if ($o->type == 126) - $o->type = 9; - - } elseif (str_starts_with($attr, 'Service Activation==')) { - $date = str_replace('Service Activation==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Relocation:')) { - $date = str_replace('Relocation:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Date:')) { - $date = str_replace('Date:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Old Service==')) { - $string = str_replace('Old Service==','',$attr); - array_push($newattrs,['old_service'=>$string]); - - } elseif (str_starts_with($attr, 'Traffic From==')) { - $string = str_replace('Traffic From==','',$attr); - array_push($newattrs,['traffic_from'=>$string]); - if ($o->type == 126) - $o->type = 9; - - } elseif (str_starts_with($attr, 'Traffic To==')) { - $string = str_replace('Traffic To==','',$attr); - array_push($newattrs,['traffic_to'=>$string]); - if ($o->type == 126) - $o->type = 9; - - } elseif (str_starts_with($attr, 'Amount==')) { - $string = str_replace('Amount==','',$attr); - array_push($newattrs,['actual'=>$string]); - - } elseif (str_starts_with($attr, 'Actual==')) { - $string = str_replace('Actual==','',$attr); - array_push($newattrs,['actual'=>$string]); - - } elseif (str_starts_with($attr, 'Allowance==')) { - $string = str_replace('Allowance==','',$attr); - array_push($newattrs,['allowance'=>$string]); - - } elseif (str_starts_with($attr, 'Allowance:')) { - $string = str_replace('Allowance:','',$attr); - array_push($newattrs,['allowance'=>$string]); - - } elseif (str_starts_with($attr, 'Old Service==')) { - $string = str_replace('Old Service==','',$attr); - array_push($newattrs,['old'=>$string]); - - } elseif (str_starts_with($attr, 'New Service==')) { - $string = str_replace('New Service==','',$attr); - array_push($newattrs,['new'=>$string]); - - } elseif (str_starts_with($attr, 'Change From==')) { - $date = str_replace('Change From==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Plan Change From==')) { - $date = str_replace('Plan Change From==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Changed From==')) { - $date = str_replace('Changed From==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'From:')) { - $date = str_replace('From:','',$attr); - - try { - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - } catch (Exception $e) {} - - } elseif (str_starts_with($attr,'To:')) { - $date = str_replace('To:','',$attr); - try { - $o->stop_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - } catch (Exception $e) {} - - } elseif (str_starts_with($attr, 'Connection Date==')) { - $date = str_replace('Connection Date==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Connection: ')) { - $date = str_replace('Connection: ','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Connection:')) { - $date = str_replace('Connection:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Effective Date==')) { - $date = str_replace('Effective Date==','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Plan Change:')) { - $date = str_replace('Plan Change:','',$attr); - $o->start_at = \Carbon\Carbon::createFromFormat('Y-m-d',$date); - - } elseif (str_starts_with($attr, 'Old Plan==')) { - $string = str_replace('Old Plan==','',$attr); - array_push($newattrs,['plan_old'=>$string]); - - } elseif (str_starts_with($attr, 'Old Plan:')) { - $string = str_replace('Old Plan:','',$attr); - array_push($newattrs,['plan_old'=>$string]); - - } elseif (str_starts_with($attr, 'New Plan==')) { - $string = str_replace('New Plan==','',$attr); - array_push($newattrs,['plan_new'=>$string]); - - } elseif (str_starts_with($attr, 'New Plan:')) { - $string = str_replace('New Plan:','',$attr); - array_push($newattrs,['plan_new'=>$string]); - - } elseif (str_starts_with($attr, 'Total Download Peak==')) { - $string = str_replace('Total Download Peak==','',$attr); - array_push($newattrs,['download_peak_total'=>$string]); - - } elseif (str_starts_with($attr, 'Allowance Download Peak==')) { - $string = str_replace('Allowance Download Peak==','',$attr); - array_push($newattrs,['download_peak_allow'=>$string]); - if ($o->type == 126) - $o->type = 9; - - } elseif (str_starts_with($attr, 'Old Speed==')) { - $string = str_replace('Old Speed==','',$attr); - array_push($newattrs,['speed_old'=>$string]); - - } elseif (str_starts_with($attr, 'OldSpeed:')) { - $string = str_replace('OldSpeed:','',$attr); - array_push($newattrs,['speed_old'=>$string]); - - } elseif (str_starts_with($attr, 'New Speed==')) { - $string = str_replace('New Speed==','',$attr); - array_push($newattrs,['speed_new'=>$string]); - - } elseif (str_starts_with($attr, 'NewSpeed:')) { - $string = str_replace('NewSpeed:','',$attr); - array_push($newattrs,['speed_new'=>$string]); - - } elseif (str_starts_with($attr, 'Used==')) { - $string = str_replace('Used==','',$attr); - array_push($newattrs,['used'=>$string]); - - } elseif (str_starts_with($attr, 'Used=')) { - $string = str_replace('Used=','',$attr); - array_push($newattrs,['used'=>$string]); - - } elseif (str_starts_with($attr, 'Month Ending==')) { - $string = str_replace('Month Ending==','',$attr); - array_push($newattrs,['month'=>$string]); - - } elseif (str_starts_with($attr, 'Month==')) { - $string = str_replace('Month==','',$attr); - array_push($newattrs,['month'=>$string]); - - } elseif (str_starts_with($attr, 'Old Peak Allowance==')) { - $string = str_replace('Old Peak Allowance==','',$attr); - array_push($newattrs,['allowance_peak_old'=>$string]); - - } elseif (str_starts_with($attr, 'Old Allowance==')) { - $string = str_replace('Old Allowance==','',$attr); - array_push($newattrs,['allowance_old'=>$string]); - - } elseif (str_starts_with($attr, 'New Peak Allowance==')) { - $string = str_replace('New Peak Allowance==','',$attr); - array_push($newattrs,['allowance_peak_new'=>$string]); - - } elseif (str_starts_with($attr, 'New Allowance==')) { - $string = str_replace('New Allowance==','',$attr); - array_push($newattrs,['allowance_new'=>$string]); - - } elseif (str_starts_with($attr, 'Invoice==')) { - $string = str_replace('Invoice==','',$attr); - array_push($newattrs,['invoice'=>$string]); - - } elseif (str_starts_with($attr, 'Connection Fee==')) { - $string = str_replace('Connection Fee==','',$attr); - array_push($newattrs,['fee'=>$string]); - - } elseif (str_starts_with($attr, 'Graytech Contribution==')) { - $string = str_replace('Graytech Contribution==','',$attr); - array_push($newattrs,['discount'=>$string]); - - } elseif (str_starts_with($attr, 'Metric==')) { - $string = str_replace('Metric==','',$attr); - array_push($newattrs,['metric'=>$string]); - - } elseif (str_starts_with($attr, 'Metric:')) { - $string = str_replace('Metric:','',$attr); - array_push($newattrs,['metric'=>$string]); - - } elseif (str_starts_with($attr, 'Month:')) { - $string = str_replace('Month:','',$attr); - array_push($newattrs,['month'=>$string]); - - } elseif (str_starts_with($attr, 'Used:')) { - $string = str_replace('Used:','',$attr); - array_push($newattrs,['actual'=>$string]); - - } elseif (str_starts_with($attr, 'Ref ')) { - $string = str_replace('Ref ','',$attr); - array_push($newattrs,['ref'=>$string]); - - } elseif ( - (str_starts_with($attr, 'New Monthly Plan==')) - || (str_starts_with($attr, 'Monthly Payment==')) - || (str_starts_with($attr, 'Old Quarterly==')) - || (str_starts_with($attr, 'New Quarterly==')) - || (str_starts_with($attr, 'Old Fee==')) - || (str_starts_with($attr, 'New Fee==')) - || (str_starts_with($attr, 'Old Rate:')) - || (str_starts_with($attr, 'New Rate:')) - || (str_starts_with($attr, 'Site==')) - || (str_starts_with($attr, 'Invoiced Already:')) - || (str_starts_with($attr, 'Balance:')) - || (str_starts_with($attr, 'Contract=='))) { - // Nothing - - } else { - dd(['attr'=>$attr,'o'=>$o->getAttributes(),'service'=>$o->service->product->name,'product'=>$o->product_id ? $o->product->name : 'NONE']); - } - */ - } - - $o->attributes = $attributes; - $o->save(); - } - - Schema::table('charges', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','charge_date']); - $table->dropUnique('charges_id_account_id_site_id_unique'); - - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - $table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services'); - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -}; diff --git a/database/migrations/2022_06_13_230224_costs.php b/database/migrations/2022_06_13_230224_costs.php deleted file mode 100644 index 18b67f4..0000000 --- a/database/migrations/2022_06_13_230224_costs.php +++ /dev/null @@ -1,101 +0,0 @@ -integer('id',TRUE,TRUE); - $table->timestamps(); - $table->integer('site_id')->unsigned(); - $table->date('billed_at'); - $table->boolean('active'); - $table->integer('supplier_id')->unsigned(); - $table->string('invoice_num')->nullable(); - - $table->unique(['id','site_id']); - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); - }); - - Schema::create('cost_broadband', function (Blueprint $table) { - $table->integer('id',TRUE,TRUE); - $table->integer('site_id')->unsigned(); - $table->integer('cost_id')->unsigned(); - $table->boolean('active'); - $table->integer('service_broadband_id')->unsigned()->nullable(); - $table->integer('supplier_broadband_id')->unsigned()->nullable(); - $table->date('start_at')->nullable(); - $table->date('end_at')->nullable(); - $table->float('base')->nullable(); - $table->float('excess')->nullable(); - $table->string('reference')->nullable(); - $table->text('notes')->nullable(); - - $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); - $table->foreign(['service_broadband_id','site_id'])->references(['id','site_id'])->on('service_broadband'); - $table->foreign(['supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband'); - }); - - Schema::create('cost_phone', function (Blueprint $table) { - $table->integer('id',TRUE,TRUE); - $table->integer('site_id')->unsigned(); - $table->integer('cost_id')->unsigned(); - $table->boolean('active'); - $table->integer('service_phone_id')->unsigned()->nullable(); - $table->integer('supplier_phone_id')->unsigned()->nullable(); - $table->date('start_at')->nullable(); - $table->date('end_at')->nullable(); - $table->float('base')->nullable(); - $table->float('excess')->nullable(); - $table->string('reference')->nullable(); - $table->text('notes')->nullable(); - - $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); - $table->foreign(['service_phone_id','site_id'])->references(['id','site_id'])->on('service_phone'); - $table->foreign(['supplier_phone_id','site_id'])->references(['id','site_id'])->on('supplier_phone'); - }); - - Schema::create('cost_generic', function (Blueprint $table) { - $table->integer('id',TRUE,TRUE); - $table->integer('site_id')->unsigned(); - $table->integer('cost_id')->unsigned(); - $table->boolean('active'); - $table->integer('service_generic_id')->unsigned()->nullable(); - $table->integer('supplier_generic_id')->unsigned()->nullable(); - $table->date('start_at')->nullable(); - $table->date('end_at')->nullable(); - $table->float('base')->nullable(); - $table->float('excess')->nullable(); - $table->string('reference')->nullable(); - $table->text('notes')->nullable(); - - $table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs'); - $table->foreign(['service_generic_id','site_id'])->references(['id','site_id'])->on('service_generic'); - $table->foreign(['supplier_generic_id','site_id'])->references(['id','site_id'])->on('supplier_generic'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('cost_generic'); - Schema::dropIfExists('cost_phone'); - Schema::dropIfExists('cost_broadband'); - Schema::dropIfExists('costs'); - } -}; diff --git a/database/migrations/2022_07_29_151513_convert_checkout.php b/database/migrations/2022_07_29_151513_convert_checkout.php deleted file mode 100644 index d1e50e2..0000000 --- a/database/migrations/2022_07_29_151513_convert_checkout.php +++ /dev/null @@ -1,53 +0,0 @@ -datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - - $table->dropForeign('ab_checkout_site_id_foreign'); - $table->dropIndex('ab_checkout_id_site_id_index'); - - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - - Schema::table('payments', function (Blueprint $table) { - $table->foreign(['checkout_id','site_id'])->references(['id','site_id'])->on('checkouts'); - }); - - foreach (\App\Models\Checkout::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($x=$o->getRawOriginal('plugin_data')) { - Config::set('site',$o->site); - - $o->plugin_data = unserialize($x); - } - - $o->save(); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2022_08_02_155407_convert_domain_registrar.php b/database/migrations/2022_08_02_155407_convert_domain_registrar.php deleted file mode 100644 index ddea5d1..0000000 --- a/database/migrations/2022_08_02_155407_convert_domain_registrar.php +++ /dev/null @@ -1,70 +0,0 @@ -datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - - $table->dropForeign('ab_domain_registrar_site_id_foreign'); - $table->dropIndex('ab_domain_registrar_id_site_id_index'); - - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - - Schema::table('service_domain', function (Blueprint $table) { - $table->foreign(['domain_registrar_id','site_id'])->references(['id','site_id'])->on('domain_registrars'); - }); - - DB::statement('RENAME TABLE ab_host_server TO supplier_host_servers'); - DB::statement('ALTER TABLE supplier_host_servers MODIFY active tinyint(1) DEFAULT NULL,MODIFY debug tinyint(1) DEFAULT NULL'); - DB::statement('ALTER TABLE supplier_host_servers MODIFY id int unsigned auto_increment,MODIFY site_id int unsigned NOT NULL,MODIFY max_accounts int unsigned DEFAULT NULL'); - DB::statement('ALTER TABLE supplier_host_servers MODIFY notes longtext DEFAULT NULL'); - - Schema::table('supplier_host_servers', function (Blueprint $table) { - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - - $table->integer('supplier_id')->unsigned()->nullable(); - - $table->foreign(['site_id'])->references(['id'])->on('sites'); - $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); - }); - - DB::statement('ALTER TABLE service_host RENAME COLUMN host_server_id TO supplier_host_server_id'); - DB::statement('ALTER TABLE service_host MODIFY supplier_host_server_id int unsigned DEFAULT NULL'); - - Schema::table('service_host', function (Blueprint $table) { - $table->foreign(['supplier_host_server_id','site_id'])->references(['id','site_id'])->on('supplier_host_servers'); - }); - - DB::statement('DROP TABLE ab_domain_tld'); - //delete from ab_host_server where id=0; - //alter table service_host modify host_server_id int unsigned default null; - //update service_host set host_server_id=NULL where host_server_id=0 - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2022_08_06_140410_supplier_constraint.php b/database/migrations/2022_08_06_140410_supplier_constraint.php deleted file mode 100644 index 3005acd..0000000 --- a/database/migrations/2022_08_06_140410_supplier_constraint.php +++ /dev/null @@ -1,46 +0,0 @@ -foreign(['supplier_id'])->references(['id'])->on('suppliers'); - }); - - Schema::create('supplier_user', function (Blueprint $table) { - $table->integer('site_id')->unsigned(); - $table->integer('supplier_id')->unsigned(); - $table->integer('user_id')->unsigned(); - $table->string('id'); - $table->dateTime('created_at'); - - $table->unique(['supplier_id','user_id']); - $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('supplier_details', function (Blueprint $table) { - $table->dropForeign(['supplier_id']); - }); - - Schema::dropIfExists('supplier_user'); - } -}; diff --git a/database/migrations/2022_08_11_101411_accounting.php b/database/migrations/2022_08_11_101411_accounting.php deleted file mode 100644 index fdb1836..0000000 --- a/database/migrations/2022_08_11_101411_accounting.php +++ /dev/null @@ -1,111 +0,0 @@ -dropForeign('ab_oauth_site_id_foreign'); - $table->dropIndex('ab_oauth_id_site_id_index'); - $table->dropIndex('ab_oauth_site_id_foreign'); - - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - - DB::statement('RENAME TABLE quickbooks_tokens TO provider_tokens'); - DB::statement('ALTER TABLE provider_tokens MODIFY realm_id TEXT DEFAULT NULL,MODIFY access_token TEXT NOT NULL,MODIFY refresh_token TEXT DEFAULT NULL'); - DB::statement('ALTER TABLE provider_tokens MODIFY access_token_expires_at datetime DEFAULT NULL,MODIFY refresh_token_expires_at datetime DEFAULT NULL'); - - Schema::table('provider_tokens', function (Blueprint $table) { - $table->integer('provider_oauth_id')->unsigned(); - $table->integer('site_id')->unsigned(); - - $table->unique(['provider_oauth_id','user_id']); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); - }); - - // delete from ab_account_oauth where account_id=144; - // update ab_account_oauth set user_id =1 where account_id=1; - // update ab_account_oauth set user_id =109 where id=12; - DB::statement('RENAME TABLE ab_account_oauth TO user_oauth'); - DB::statement('ALTER TABLE user_oauth RENAME COLUMN oauth_id TO provider_oauth_id'); - Schema::table('user_oauth', function (Blueprint $table) { - $table->datetime('created_at')->nullable()->after('id'); - $table->datetime('updated_at')->nullable()->after('created_at'); - }); - - foreach (\App\Models\UserOauth::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - - if ($o->getRawOriginal('oauth_data') && ! is_array($o->oauth_data)) { - try { - $o->oauth_data = unserialize(gzuncompress($o->getRawOriginal('oauth_data'))); - } catch (Exception $e) { - } - } - - $o->save(); - } - - DB::statement('ALTER TABLE user_oauth MODIFY provider_oauth_id int unsigned NOT NULL'); - Schema::table('user_oauth', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_last','account_id']); - $table->dropForeign('ab_account_oauth_site_id_foreign'); - $table->dropIndex('ab_account_oauth_site_id_foreign'); - $table->dropIndex('ab_account_oauth_id_site_id_index'); - $table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users'); - $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); - }); - - // Fix incorrect site references - Schema::table('accounts', function (Blueprint $table) { - $table->dropForeign(['site_id']); - }); - Schema::table('services', function (Blueprint $table) { - $table->dropForeign(['site_id']); - }); - Schema::table('costs', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - Schema::table('products', function (Blueprint $table) { - $table->dropForeign(['site_id']); - $table->foreign(['site_id'])->references(['id'])->on('sites'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -}; diff --git a/database/migrations/2022_08_15_171005_qb_account_sync.php b/database/migrations/2022_08_15_171005_qb_account_sync.php deleted file mode 100644 index 8d0625b..0000000 --- a/database/migrations/2022_08_15_171005_qb_account_sync.php +++ /dev/null @@ -1,38 +0,0 @@ -timestamps(); - $table->integer('account_id')->unsigned(); - $table->integer('provider_oauth_id')->unsigned(); - $table->integer('site_id')->unsigned(); - $table->string('ref'); - $table->integer('synctoken'); - - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('account_provider'); - } -}; diff --git a/database/migrations/2022_08_19_133535_fix_siteid.php b/database/migrations/2022_08_19_133535_fix_siteid.php deleted file mode 100644 index ca4fe57..0000000 --- a/database/migrations/2022_08_19_133535_fix_siteid.php +++ /dev/null @@ -1,52 +0,0 @@ -dropForeign(['site_id']); - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - }); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -}; diff --git a/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php b/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php deleted file mode 100644 index c19ae92..0000000 --- a/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php +++ /dev/null @@ -1,28 +0,0 @@ -dropForeign('ab_product_translate_site_id_foreign'); - $table->dropIndex('ab_product_translate_id_site_id_index'); - $table->dropIndex('ab_product_translate_site_id_foreign'); - - $table->foreign(['language_id'])->references(['id'])->on('languages'); - $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2023_05_03_223721_product_model.php b/database/migrations/2023_05_03_223721_product_model.php deleted file mode 100644 index 5bdff1b..0000000 --- a/database/migrations/2023_05_03_223721_product_model.php +++ /dev/null @@ -1,32 +0,0 @@ -index(['id','site_id']); - }); - - DB::statement('ALTER TABLE groups MODIFY COLUMN id INT unsigned auto_increment'); - - DB::statement('UPDATE groups set id=0 where id=1 and name="All Users"'); - - Schema::table('groups', function (Blueprint $table) { - $table->foreign(['site_id'])->references(['site_id'])->on('sites'); - $table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('groups'); - $table->dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - $table->dateTime('start_at')->nullable()->after('updated_at'); - $table->dateTime('expire_at')->nullable()->after('start_at'); - }); - - // Convert out dates - foreach (\App\Models\Group::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - // If we are running again - if ($o->created_at) - continue; - - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->date_expire) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire); - if ($o->date_start) - $o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start); - - $o->save(); - } - - Schema::table('groups', function (Blueprint $table) { - $table->dropColumn(['date_orig','date_expire','date_start']); - }); - - // ACCOUNT GROUP - - DB::statement('DELETE FROM ab_account_group where id=1 and group_id=0 and account_id=0'); - Schema::table('ab_account_group', function (Blueprint $table) { - $table->dropPrimary(['id','site_id','account_id','group_id']); - $table->dropForeign('ab_account_group_site_id_foreign'); - $table->dropIndex('ab_account_group_site_id_foreign'); - - $table->dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - $table->dateTime('start_at')->nullable()->after('updated_at'); - $table->dateTime('expire_at')->nullable()->after('start_at'); - }); - - DB::statement('ALTER TABLE ab_account_group RENAME TO account_group'); - Schema::table('account_group', function (Blueprint $table) { - $table->index(['id','site_id']); - }); - - // Convert out dates - foreach (\App\Models\AccountGroup::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - // If we are running again - if ($o->created_at) - continue; - - if ($o->date_orig) - $o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig); - if ($o->date_last) - $o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last); - if ($o->date_expire) - $o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire); - if ($o->date_start) - $o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start); - - $o->save(); - } - - DB::statement('ALTER TABLE account_group MODIFY group_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE account_group MODIFY account_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE account_group MODIFY active tinyint(1) NOT NULL'); - - Schema::table('account_group', function (Blueprint $table) { - $table->dropIndex('ab_account_group_id_site_id_index'); - $table->dropColumn(['date_orig','date_expire','date_start','service_id']); - $table->unique(['account_id','site_id']); - - $table->foreign(['group_id','site_id'])->references(['id','site_id'])->on('groups'); - $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2023_05_05_104307_product_id_increase.php b/database/migrations/2023_05_05_104307_product_id_increase.php deleted file mode 100644 index a68457a..0000000 --- a/database/migrations/2023_05_05_104307_product_id_increase.php +++ /dev/null @@ -1,37 +0,0 @@ -dropColumn(['price_type']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'Cant go back'); - } -}; diff --git a/database/migrations/2023_05_05_234120_service_change_update.php b/database/migrations/2023_05_05_234120_service_change_update.php deleted file mode 100644 index 9f3e4d4..0000000 --- a/database/migrations/2023_05_05_234120_service_change_update.php +++ /dev/null @@ -1,100 +0,0 @@ -dateTime('created_at')->nullable()->after('id'); - $table->dateTime('updated_at')->nullable()->after('created_at'); - $table->date('ordered_at')->nullable()->after('ordered_by'); - $table->date('effective_at')->nullable()->after('ordered_at'); - $table->text('notes')->nullable(); - }); - - DB::statement('ALTER TABLE service__change MODIFY service_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service__change MODIFY product_id int unsigned NOT NULL'); - DB::statement('ALTER TABLE service__change MODIFY ordered_by int unsigned NOT NULL'); - - DB::statement('ALTER TABLE service__change MODIFY active tinyint(1) NOT NULL'); - DB::statement('ALTER TABLE service__change MODIFY complete tinyint(1) NOT NULL'); - - // Convert out dates - foreach (\App\Models\ServiceChange::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - // If we are running again - if ($o->created_at) - continue; - - if ($o->ordered_at_old) - $o->created_at = \Carbon\Carbon::create(substr($o->ordered_at_old,0,4),substr($o->ordered_at_old,4,2),substr($o->ordered_at_old,6,2)); - - $o->updated_at = $o->created_at; - $o->ordered_at = $o->created_at; - - if ($o->effective_at_old) - $o->effective_at = \Carbon\Carbon::create(substr($o->effective_at_old,0,4),substr($o->effective_at_old,4,2),substr($o->effective_at_old,6,2)); - - $o->save(); - } - - Schema::table('service__change', function (Blueprint $table) { - $table->dropColumn(['ordered_at_old','effective_at_old']); - }); - - DB::statement('ALTER TABLE service__change MODIFY ordered_at date NOT NULL'); - - foreach (\App\Models\Service::where('order_info','LIKE','%change%')->withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - if ($o->order_info->only(['change_note','change_product_id','change_date'])->count() !== 3) - continue; - - $o->changes()->attach([$o->id => [ - 'site_id'=> $o->site_id, - 'ordered_by' => 1, - 'ordered_at' => $x=\Carbon\Carbon::createFromDate(\Illuminate\Support\Arr::get($o->order_info,'change_date')), - 'effective_at' => $x, - 'product_id' => \Illuminate\Support\Arr::get($o->order_info,'change_product_id'), - 'notes' => \Illuminate\Support\Arr::get($o->order_info,'change_note'), - 'active' => true, - 'complete' => true, - ]]); - - $o->order_info->forget(['change_note','change_product_id','change_date']); - $o->save(); - } - - // Additional cleanup - foreach (\App\Models\Service::whereNotNull('order_info')->withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) { - foreach (['notes','provision_notes','cancel_note'] as $key) { - if ($o->order_info && ((is_array($o->order_info) && array_key_exists($key,$o->order_info)) || ($o->order_info->has($key))) && is_null(\Illuminate\Support\Arr::get($o->order_info,$key))) - $o->order_info->forget($key); - } - - $o->save(); - } - - // Final cleanup - DB::statement("UPDATE services set order_info=null WHERE order_info='[]'"); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -}; diff --git a/database/migrations/2023_05_10_172738_rename_account_provider.php b/database/migrations/2023_05_10_172738_rename_account_provider.php deleted file mode 100644 index 83e7a58..0000000 --- a/database/migrations/2023_05_10_172738_rename_account_provider.php +++ /dev/null @@ -1,38 +0,0 @@ -dropForeign(['account_id', 'site_id']); - $table->dropForeign(['provider_oauth_id', 'site_id']); - $table->dropIndex('account_provider_account_id_site_id_foreign'); - $table->dropIndex('account_provider_provider_oauth_id_site_id_foreign'); - }); - DB::statement('ALTER TABLE account_provider RENAME TO account__provider'); - Schema::table('account__provider', function (Blueprint $table) { - $table->foreign(['account_id', 'site_id'])->references(['id', 'site_id'])->on('accounts'); - $table->foreign(['provider_oauth_id', 'site_id'])->references(['id', 'site_id'])->on('provider_oauth'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - abort(500,'cant go back'); - } -}; diff --git a/database/migrations/2023_05_13_142113_accounting_payment.php b/database/migrations/2023_05_13_142113_accounting_payment.php deleted file mode 100644 index 644df17..0000000 --- a/database/migrations/2023_05_13_142113_accounting_payment.php +++ /dev/null @@ -1,38 +0,0 @@ -timestamps(); - $table->integer('payment_id')->unsigned(); - $table->integer('provider_oauth_id')->unsigned(); - $table->integer('site_id')->unsigned(); - $table->string('ref'); - $table->integer('synctoken'); - - $table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments'); - $table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('payment__provider'); - } -};