Merge branch 'master' into Development
This commit is contained in:
@@ -11,43 +11,43 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('person_types', function(Blueprint $table){
|
||||
Schema::create('person_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('person_groups', function(Blueprint $table){
|
||||
Schema::create('person_groups', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->string('color_tag', 50)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('phone_types', function(Blueprint $table){
|
||||
Schema::create('phone_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('address_types', function(Blueprint $table){
|
||||
Schema::create('address_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
|
||||
Schema::create('person', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
@@ -55,11 +55,11 @@ public function up(): void
|
||||
$table->string('first_name', 255)->nullable();
|
||||
$table->string('last_name', 255)->nullable();
|
||||
$table->string('full_name', 255)->nullable();
|
||||
$table->enum('gender', ['m','w'])->nullable();
|
||||
$table->enum('gender', ['m', 'w'])->nullable();
|
||||
$table->date('birthday')->nullable();
|
||||
$table->string('tax_number', 99)->nullable();
|
||||
$table->string('social_security_number',99)->nullable();
|
||||
$table->string('description',500)->nullable();
|
||||
$table->string('social_security_number', 99)->nullable();
|
||||
$table->string('description', 500)->nullable();
|
||||
$table->foreignId('group_id')->references('id')->on('person_groups');
|
||||
$table->foreignId('type_id')->references('id')->on('person_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
@@ -68,12 +68,12 @@ public function up(): void
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('person_phones', function(Blueprint $table){
|
||||
Schema::create('person_phones', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nu',50);
|
||||
$table->string('nu', 50);
|
||||
$table->unsignedInteger('country_code')->nullable();
|
||||
$table->foreignId('type_id')->references('id')->on('phone_types');
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class);
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->softDeletes();
|
||||
@@ -82,12 +82,12 @@ public function up(): void
|
||||
|
||||
});
|
||||
|
||||
Schema::create('person_addresses', function(Blueprint $table){
|
||||
Schema::create('person_addresses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('address',150);
|
||||
$table->string('address', 150);
|
||||
$table->string('country')->nullable();
|
||||
$table->foreignId('type_id')->references('id')->on('address_types');
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class);
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('account_types', function(Blueprint $table){
|
||||
Schema::create('account_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
@@ -11,26 +11,25 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('debt_types', function(Blueprint $table){
|
||||
Schema::create('debt_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50)->unique();
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50)->unique();
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
|
||||
Schema::create('debts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference',125)->nullable();
|
||||
$table->string('invoice_nu',125)->nullable();
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->string('invoice_nu', 125)->nullable();
|
||||
$table->date('issue_date')->nullable();
|
||||
$table->date('due_date')->nullable();
|
||||
$table->decimal('amount', 11, 4)->nullable();
|
||||
$table->decimal('interest', 11, 8)->nullable();
|
||||
$table->date('interest_start_date')->nullable();
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->foreignId('account_id')->references('id')->on('accounts');
|
||||
$table->foreignId('type_id')->references('id')->on('debt_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payment_types', function(Blueprint $table){
|
||||
Schema::create('payment_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
});
|
||||
|
||||
Schema::create('payments', function (Blueprint $table) {
|
||||
@@ -26,7 +25,7 @@ public function up(): void
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->string('payment_nu', 125)->nullable();
|
||||
$table->date('payment_date')->nullable();
|
||||
$table->decimal('amount',11,4)->nullable();
|
||||
$table->decimal('amount', 11, 4)->nullable();
|
||||
$table->foreignId('debt_id')->references('id')->on('debts');
|
||||
$table->foreignId('type_id')->references('id')->on('payment_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contract_types', function(Blueprint $table){
|
||||
Schema::create('contract_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 125)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->decimal("initial_amount", 20, 4)->default(0);
|
||||
$table->decimal("balance_amount", 20, 4)->default(0);
|
||||
$table->date("promise_date")->nullable();
|
||||
$table->decimal('initial_amount', 20, 4)->default(0);
|
||||
$table->decimal('balance_amount', 20, 4)->default(0);
|
||||
$table->date('promise_date')->nullable();
|
||||
$table->index('balance_amount');
|
||||
$table->index('promise_date');
|
||||
});
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -36,7 +37,7 @@ public function up(): void
|
||||
$table->index('iban');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,35 +10,35 @@ public function up(): void
|
||||
{
|
||||
// People: unique by (tax_number, social_security_number, deleted_at)
|
||||
Schema::table('person', function (Blueprint $table) {
|
||||
if (!self::hasIndex('person', 'person_identity_unique')) {
|
||||
if (! self::hasIndex('person', 'person_identity_unique')) {
|
||||
$table->unique(['tax_number', 'social_security_number', 'deleted_at'], 'person_identity_unique');
|
||||
}
|
||||
});
|
||||
|
||||
// Phones: unique by (person_id, nu, country_code, deleted_at)
|
||||
Schema::table('person_phones', function (Blueprint $table) {
|
||||
if (!self::hasIndex('person_phones', 'person_phones_unique')) {
|
||||
if (! self::hasIndex('person_phones', 'person_phones_unique')) {
|
||||
$table->unique(['person_id', 'nu', 'country_code', 'deleted_at'], 'person_phones_unique');
|
||||
}
|
||||
});
|
||||
|
||||
// Addresses: unique by (person_id, address, country, deleted_at)
|
||||
Schema::table('person_addresses', function (Blueprint $table) {
|
||||
if (!self::hasIndex('person_addresses', 'person_addresses_unique')) {
|
||||
if (! self::hasIndex('person_addresses', 'person_addresses_unique')) {
|
||||
$table->unique(['person_id', 'address', 'country', 'deleted_at'], 'person_addresses_unique');
|
||||
}
|
||||
});
|
||||
|
||||
// Contracts: unique by (client_case_id, reference, deleted_at)
|
||||
Schema::table('contracts', function (Blueprint $table) {
|
||||
if (!self::hasIndex('contracts', 'contracts_reference_unique')) {
|
||||
if (! self::hasIndex('contracts', 'contracts_reference_unique')) {
|
||||
$table->unique(['client_case_id', 'reference', 'deleted_at'], 'contracts_reference_unique');
|
||||
}
|
||||
});
|
||||
|
||||
// Accounts: unique by (contract_id, reference, deleted_at)
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
if (!self::hasIndex('accounts', 'accounts_reference_unique')) {
|
||||
if (! self::hasIndex('accounts', 'accounts_reference_unique')) {
|
||||
$table->unique(['contract_id', 'reference', 'deleted_at'], 'accounts_reference_unique');
|
||||
}
|
||||
});
|
||||
@@ -70,6 +70,7 @@ private static function hasIndex(string $table, string $index): bool
|
||||
$connection = Schema::getConnection();
|
||||
$schemaManager = $connection->getDoctrineSchemaManager();
|
||||
$doctrineTable = $schemaManager->listTableDetails($table);
|
||||
|
||||
return $doctrineTable->hasIndex($index);
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
|
||||
if (!Schema::hasColumn('accounts', 'balance_amount')) {
|
||||
|
||||
|
||||
if (! Schema::hasColumn('accounts', 'balance_amount')) {
|
||||
|
||||
$table->decimal('balance_amount', 18, 4)->nullable()->after('description');
|
||||
$table->index('balance_amount');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('imports', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('imports', 'import_template_id')) {
|
||||
if (! Schema::hasColumn('imports', 'import_template_id')) {
|
||||
$table->foreignId('import_template_id')->nullable();
|
||||
}
|
||||
// Add foreign key if not exists (Postgres will error if duplicate, so wrap in try/catch in runtime, but Schema builder doesn't support conditional FKs)
|
||||
|
||||
@@ -29,8 +29,9 @@ public function up(): void
|
||||
$used = [];
|
||||
foreach ($rows as $row) {
|
||||
if (is_string($row->nu) && preg_match('/^[A-Za-z0-9]{6}$/', $row->nu)) {
|
||||
if (!isset($used[$row->nu])) {
|
||||
if (! isset($used[$row->nu])) {
|
||||
$used[$row->nu] = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
// duplicate will be regenerated below
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('import_mappings', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('import_mappings', 'position')) {
|
||||
if (! Schema::hasColumn('import_mappings', 'position')) {
|
||||
$table->unsignedInteger('position')->nullable()->after('options');
|
||||
}
|
||||
$table->index(['import_id', 'position']);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('import_mappings', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('import_mappings', 'entity')) {
|
||||
if (! Schema::hasColumn('import_mappings', 'entity')) {
|
||||
$table->string('entity', 64)->nullable()->after('import_id');
|
||||
}
|
||||
$table->index(['import_id', 'entity']);
|
||||
@@ -19,9 +19,11 @@ public function up(): void
|
||||
// Backfill entity from target_field's first segment where possible
|
||||
DB::table('import_mappings')->orderBy('id')->chunkById(1000, function ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if (!empty($row->entity)) continue;
|
||||
if (! empty($row->entity)) {
|
||||
continue;
|
||||
}
|
||||
$entity = null;
|
||||
if (!empty($row->target_field)) {
|
||||
if (! empty($row->target_field)) {
|
||||
$parts = explode('.', $row->target_field);
|
||||
$record = $parts[0] ?? null;
|
||||
if ($record) {
|
||||
@@ -49,7 +51,10 @@ public function down(): void
|
||||
Schema::table('import_mappings', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('import_mappings', 'entity')) {
|
||||
// drop composite index if exists
|
||||
try { $table->dropIndex(['import_id', 'entity']); } catch (\Throwable $e) { /* ignore */ }
|
||||
try {
|
||||
$table->dropIndex(['import_id', 'entity']);
|
||||
} catch (\Throwable $e) { /* ignore */
|
||||
}
|
||||
$table->dropColumn('entity');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('import_template_mappings', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('import_template_mappings', 'entity')) {
|
||||
if (! Schema::hasColumn('import_template_mappings', 'entity')) {
|
||||
$table->string('entity', 64)->nullable()->after('import_template_id');
|
||||
}
|
||||
$table->index(['import_template_id', 'entity']);
|
||||
@@ -19,9 +19,11 @@ public function up(): void
|
||||
// Backfill entity from target_field first segment
|
||||
DB::table('import_template_mappings')->orderBy('id')->chunkById(1000, function ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if (!empty($row->entity)) continue;
|
||||
if (! empty($row->entity)) {
|
||||
continue;
|
||||
}
|
||||
$entity = null;
|
||||
if (!empty($row->target_field)) {
|
||||
if (! empty($row->target_field)) {
|
||||
$parts = explode('.', $row->target_field);
|
||||
$record = $parts[0] ?? null;
|
||||
if ($record) {
|
||||
@@ -47,7 +49,10 @@ public function down(): void
|
||||
{
|
||||
Schema::table('import_template_mappings', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('import_template_mappings', 'entity')) {
|
||||
try { $table->dropIndex(['import_template_id', 'entity']); } catch (\Throwable $e) { /* ignore */ }
|
||||
try {
|
||||
$table->dropIndex(['import_template_id', 'entity']);
|
||||
} catch (\Throwable $e) { /* ignore */
|
||||
}
|
||||
$table->dropColumn('entity');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('field_job_settings', function (Blueprint $table) {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('field_jobs', function (Blueprint $table) {
|
||||
|
||||
@@ -33,8 +33,8 @@ public function up(): void
|
||||
$table->unique(['contract_type_id', 'segment_id']);
|
||||
});
|
||||
|
||||
// Mark existing rows as initial
|
||||
\DB::table('contract_configs')->update(['is_initial' => true]);
|
||||
// Mark existing rows as initial
|
||||
\DB::table('contract_configs')->update(['is_initial' => true]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
|
||||
+6
-2
@@ -26,9 +26,13 @@ public function up(): void
|
||||
|
||||
$keepFirst = true;
|
||||
foreach ($rows as $row) {
|
||||
if ($keepFirst) { $keepFirst = false; continue; }
|
||||
if ($keepFirst) {
|
||||
$keepFirst = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
$base = mb_substr($row->reference, 0, 120);
|
||||
$newRef = $base . '-' . $row->id;
|
||||
$newRef = $base.'-'.$row->id;
|
||||
DB::table('contracts')->where('id', $row->id)->update(['reference' => $newRef]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('active')->default(true)->after('email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('active');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user