Skip to content

Commit

Permalink
Database: Re-factoring
Browse files Browse the repository at this point in the history
- Add some new column into table to provided some variable
	: - batchName -> this for preserve if process or task is batch process,
					if task is batch then they will have unique name. And on previous condition
					that unique name will replace original filename or are not replaced anything
					inside database.
	  - groupId	  -> this for preserve batch process, actually rename from batchId,
					and will blast to some of table. So it can be search by using groupId for mass
					search.
- Correctly define column requirement for each table (Not set as text for all)

Signed-off-by: Dicky Herlambang (花) <herlambangdicky5@gmail.com>
  • Loading branch information
Nicklas373 committed Nov 5, 2024
1 parent 31b19f9 commit 0623e20
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 158 deletions.
20 changes: 0 additions & 20 deletions app/Models/AccessLogModel.php

This file was deleted.

6 changes: 5 additions & 1 deletion app/Models/AppLogModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ class appLogModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'appLogs';
protected $primaryKey = 'processId';
protected $keyType = 'string';

protected $fillable = [
'processId',
'groupId',
'errReason',
'errStatus'
];
}
}
6 changes: 5 additions & 1 deletion app/Models/JobLogModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ class jobLogModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'jobLogs';
protected $primaryKey = 'jobsId';
protected $keyType = 'string';

protected $fillable = [
'jobsId',
'jobsName',
'jobsEnv',
'jobsRuntime',
'jobsResult',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
Expand Down
4 changes: 3 additions & 1 deletion app/Models/NotifyLogModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class notifyLogModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'notifyLogs';
protected $primaryKey = 'notifyId';
protected $keyType = 'string';

protected $fillable = [
'notifyId',
'processId',
'notifyName',
'notifyResult',
Expand Down
11 changes: 7 additions & 4 deletions app/Models/cnvModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ class cnvModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfConvert';
protected $primaryKey = 'cnvId';
protected $keyType = 'string';

protected $fillable = [
'cnvId',
'fileName',
'fileSize',
'container',
'imgExtract',
'result',
'isBatch',
'batchId',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
11 changes: 7 additions & 4 deletions app/Models/compressModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ class compressModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $primaryKey = 'compressId';
protected $table = 'pdfCompress';
protected $keyType = 'string';

protected $fillable = [
'compressId',
'fileName',
'fileSize',
'compFileSize',
'compMethod',
'result',
'isBatch',
'batchId',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
9 changes: 6 additions & 3 deletions app/Models/htmlModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ class htmlModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfHtml';
protected $primaryKey = 'htmlId';
protected $keyType = 'string';

protected $fillable = [
'htmlId',
'urlName',
'urlMargin',
'urlOrientation',
'urlSinglePage',
'urlSize',
'result',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
11 changes: 7 additions & 4 deletions app/Models/mergeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ class mergeModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfMerge';
protected $primaryKey = 'mergeId';
protected $keyType = 'string';

protected $fillable = [
'mergeId',
'fileName',
'fileSize',
'result',
'isBatch',
'batchId',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
11 changes: 7 additions & 4 deletions app/Models/splitModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class splitModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfSplit';
protected $primaryKey = 'splitId';
protected $keyType = 'string';

protected $fillable = [
'splitId',
'fileName',
'fileSize',
'fromPage',
Expand All @@ -24,10 +26,11 @@ class splitModel extends Model
'action',
'result',
'isBatch',
'batchId',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
11 changes: 7 additions & 4 deletions app/Models/watermarkModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class watermarkModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfWatermark';
protected $primaryKey = 'watermarkId';
protected $keyType = 'string';

protected $fillable = [
'watermarkId',
'fileName',
'fileSize',
'watermarkFontFamily',
Expand All @@ -28,10 +30,11 @@ class watermarkModel extends Model
'watermarkPage',
'result',
'isBatch',
'batchId',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration',
'isReport'
'procDuration'
];
}
10 changes: 4 additions & 6 deletions database/migrations/2024_09_11_232910_create_app_logs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
public function up(): void
{
Schema::create('appLogs', function (Blueprint $table) {
$table->uuid('processId');
$table->uuid('processId')->primary()->unique();
$table->uuid('groupId');
$table->text('errReason')->nullable();
$table->text('errStatus')->nullable();
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();

// Configure primary key
$table->primary('processId');
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign keys
$table->foreign('processId')->references('processId')->on('pdfCompress')->name('pdf_compress_fk');
$table->foreign('processId')->references('processId')->on('pdfMerge')->name('pdf_merge_fk');
$table->foreign('processId')->references('processId')->on('pdfSplit')->name('pdf_split_fk');
$table->foreign('processId')->references('processId')->on('pdfDelete')->name('pdf_delete_fk');
$table->foreign('processId')->references('processId')->on('pdfCnv')->name('pdf_cnv_fk');
$table->foreign('processId')->references('processId')->on('pdfWatermark')->name('pdf_watermark_fk');
$table->foreign('processId')->references('processId')->on('pdfHtml')->name('pdf_html_fk');
Expand Down
15 changes: 8 additions & 7 deletions database/migrations/2024_09_11_232920_create_cnv_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
public function up(): void
{
Schema::create('pdfConvert', function (Blueprint $table) {
$table->id('cnvId');
$table->id('cnvId')->primary()->unique();
$table->text('fileName')->nullable();
$table->string('fileSize', 25)->nullable();
$table->string('container', 25)->nullable();
$table->char('fileSize', length: 25)->nullable();
$table->enum('container', ['jpg','docx','pptx','xlsx','pdf'])->nullable();
$table->boolean('imgExtract');
$table->boolean('result');
$table->boolean('isBatch');
$table->uuid('processId');
$table->uuid('batchId')->nullable();
$table->text('batchName')->nullable();
$table->uuid('groupId');
$table->uuid('processId')->unique();
$table->timestamp('procStartAt')->nullable();
$table->timestamp('procEndAt')->nullable();
$table->text('procDuration')->nullable();
$table->char('procDuration', length: 25)->nullable();
$table->boolean('isReport')->nullable()->default(false);
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign key
Expand Down
17 changes: 9 additions & 8 deletions database/migrations/2024_09_11_232924_create_compress_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
public function up(): void
{
Schema::create('pdfCompress', function (Blueprint $table) {
$table->id('compressId');
$table->id('compressId')->primary()->unique();
$table->text('fileName')->nullable();
$table->string('fileSize', 25)->nullable();
$table->string('compFileSize', 25)->nullable();
$table->string('compMethod', 25)->nullable();
$table->char('fileSize', length: 25)->nullable();
$table->char('compFileSize', length: 25)->nullable();
$table->enum('compMethod', ['low','recommended','extreme'])->nullable();
$table->boolean('result');
$table->boolean('isBatch');
$table->uuid('processId');
$table->uuid('batchId')->nullable();
$table->text('batchName')->nullable();
$table->uuid('groupId');
$table->uuid('processId')->unique();
$table->timestamp('procStartAt')->nullable();
$table->timestamp('procEndAt')->nullable();
$table->text('procDuration')->nullable();
$table->char('procDuration', length: 25)->nullable();
$table->boolean('isReport')->nullable()->default(false);
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign key
Expand Down
15 changes: 8 additions & 7 deletions database/migrations/2024_09_11_232931_create_html_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
public function up(): void
{
Schema::create('pdfHtml', function (Blueprint $table) {
$table->id('htmlId');
$table->id('htmlId')->primary()->unique();
$table->text('urlName')->nullable();
$table->text('urlMargin')->nullable();
$table->text('urlOrientation')->nullable();
$table->integer('urlMargin')->nullable();
$table->enum('urlOrientation', ['landscape','portrait'])->nullable();
$table->boolean('urlSinglePage')->nullable();
$table->text('urlSize')->nullable();
$table->enum('urlSize', ['A3','A4','A5','Letter'])->nullable();
$table->boolean('result');
$table->uuid('processId');
$table->uuid('groupId');
$table->uuid('processId')->unique();
$table->timestamp('procStartAt')->nullable();
$table->timestamp('procEndAt')->nullable();
$table->text('procDuration')->nullable();
$table->char('procDuration', length: 25)->nullable();
$table->boolean('isReport')->nullable()->default(false);
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign key
Expand Down
16 changes: 9 additions & 7 deletions database/migrations/2024_09_11_232937_create_job_logs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
public function up(): void
{
Schema::create('jobLogs', function (Blueprint $table) {
$table->id('jobsId');
$table->string('jobsName', 25);
$table->string('jobsEnv', 25);
$table->string('jobsRuntime', 25);
$table->id('jobsId')->primary()->unique();
$table->char('jobsName', length: 25);
$table->enum('jobsEnv', ['production', 'local']);
$table->char('jobsRuntime', length: 25);
$table->boolean('jobsResult');
$table->uuid('groupId');
$table->uuid('processId')->unique();
$table->timestamp('procStartAt')->nullable();
$table->timestamp('procEndAt')->nullable();
$table->text('procDuration')->nullable();
$table->uuid('processId');
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->char('procDuration', length: 25)->nullable();
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign key
$table->foreign('processId')->references('processId')->on('appLogs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
public function up(): void
{
Schema::create('notifyLogs', function (Blueprint $table) {
$table->id('notifyId');
$table->uuid('processId');
$table->string('notifyName', 25);
$table->id('notifyId')->primary()->unique();
$table->uuid('processId')->unique();
$table->char('notifyName', length: 25);
$table->boolean('notifyResult');
$table->text('notifyMessage')->nullable();
$table->json('notifyResponse')->nullable();
$table->timestamp('createdAt')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('created_at')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

// Configure foreign key
$table->foreign('processId')->references('processId')->on('appLogs');
Expand Down
Loading

0 comments on commit 0623e20

Please sign in to comment.