Skip to content

Commit

Permalink
alter table for master
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt committed Jun 12, 2020
1 parent e822411 commit 90f6d7f
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 8 deletions.
53 changes: 49 additions & 4 deletions app/Console/Commands/AlterTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,55 @@ public function handle()
$this->line('Alter '.$project->code);
config()->set('database.connections.tenant.database', $db);
DB::connection('tenant')->reconnect();
DB::connection('tenant')->statement('ALTER TABLE `kpis` ADD COLUMN `comment` text default null');
DB::connection('tenant')->statement('ALTER TABLE `kpi_templates` ADD COLUMN `archived_at` timestamp null default null');
DB::connection('tenant')->statement('ALTER TABLE `kpi_templates` ADD COLUMN `archived_by` integer(10) unsigned default null');
DB::connection('tenant')->statement('ALTER TABLE `kpi_templates` ADD CONSTRAINT `kpis_templates_archived_by_foreign` FOREIGN KEY (`archived_by`) REFERENCES users (`id`) ON DELETE RESTRICT');

DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `address` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `city` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `state` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `country` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `zip_code` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `latitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `longitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `phone` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `phone_cc` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `email` varchar(255) default null');

DB::connection('tenant')->statement('ALTER TABLE `customers` DROP COLUMN `credit_ceiling`');
DB::connection('tenant')->statement('ALTER TABLE `customers` ADD COLUMN `credit_limit` decimal(65, 30) default 0');

DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `address` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `city` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `state` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `country` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `zip_code` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `latitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `longitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `phone` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `phone_cc` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `suppliers` ADD COLUMN `email` varchar(255) default null');

DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `tax_identification_number` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `address` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `city` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `state` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `country` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `zip_code` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `latitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `longitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `phone` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `phone_cc` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `expeditions` ADD COLUMN `email` varchar(255) default null');

DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `tax_identification_number` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `address` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `city` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `state` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `country` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `zip_code` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `latitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `longitude` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `phone` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `phone_cc` varchar(255) default null');
DB::connection('tenant')->statement('ALTER TABLE `employees` ADD COLUMN `email` varchar(255) default null');
}
}
}
14 changes: 12 additions & 2 deletions app/Model/Master/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ class Customer extends MasterModel

protected $appends = ['label'];

protected $casts = ['credit_ceiling' => 'double'];
protected $casts = ['credit_limit' => 'double'];

protected $fillable = [
'code',
'name',
'tax_identification_number',
'address',
'city',
'state',
'country',
'zip_code',
'latitude',
'longitude',
'phone',
'phone_cc',
'email',
'notes',
'credit_ceiling',
'credit_limit',
'pricing_group_id',
'disabled',
];
Expand Down
11 changes: 11 additions & 0 deletions app/Model/Master/Expedition.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class Expedition extends MasterModel
protected $fillable = [
'code',
'name',
'tax_identification_number',
'address',
'city',
'state',
'country',
'zip_code',
'latitude',
'longitude',
'phone',
'phone_cc',
'email',
'notes',
];
}
10 changes: 10 additions & 0 deletions app/Model/Master/Supplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class Supplier extends MasterModel
'code',
'name',
'tax_identification_number',
'address',
'city',
'state',
'country',
'zip_code',
'latitude',
'longitude',
'phone',
'phone_cc',
'email',
'notes',
'disabled',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ public function up()
Schema::create('employees', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->nullable()->unique();
$table->string('tax_identification_number')->nullable();
$table->string('name');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('country')->nullable();
$table->string('zip_code')->nullable();
$table->double('latitude')->nullable();
$table->double('longitude')->nullable();
$table->string('phone')->nullable();
$table->string('phone_cc')->nullable(); // country code
$table->string('email')->nullable();

$table->string('personal_identity')->nullable();
// Data related to personal info
$table->string('last_education')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ public function up()
$table->string('code')->nullable()->unique();
$table->string('tax_identification_number')->nullable();
$table->string('name');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('country')->nullable();
$table->string('zip_code')->nullable();
$table->double('latitude')->nullable();
$table->double('longitude')->nullable();
$table->string('phone')->nullable();
$table->string('phone_cc')->nullable(); // country code
$table->string('email')->nullable();
$table->text('notes')->nullable();
$table->decimal('credit_ceiling', 65, 30)->default(0);
$table->decimal('credit_limit', 65, 30)->default(0);
$table->unsignedInteger('branch_id')->index()->nullable();
$table->unsignedInteger('created_by')->index()->nullable();
$table->unsignedInteger('updated_by')->index()->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ public function up()
$table->string('code')->nullable()->unique();
$table->string('tax_identification_number')->nullable();
$table->string('name');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('country')->nullable();
$table->string('zip_code')->nullable();
$table->double('latitude')->nullable();
$table->double('longitude')->nullable();
$table->string('phone')->nullable();
$table->string('phone_cc')->nullable(); // country code
$table->string('email')->nullable();
$table->text('notes')->nullable();
$table->unsignedInteger('branch_id')->index()->nullable();
$table->unsignedInteger('created_by')->index()->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ public function up()
{
Schema::create('expeditions', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('code')->nullable()->unique();
$table->string('tax_identification_number')->nullable();
$table->string('name');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('country')->nullable();
$table->string('zip_code')->nullable();
$table->double('latitude')->nullable();
$table->double('longitude')->nullable();
$table->string('phone')->nullable();
$table->string('phone_cc')->nullable(); // country code
$table->string('email')->nullable();
$table->text('notes')->nullable();
$table->boolean('disabled')->default(false);
$table->unsignedInteger('created_by')->index()->nullable();
Expand Down

0 comments on commit 90f6d7f

Please sign in to comment.