Skip to content

Commit 29c8f22

Browse files
committed
refactor: change status from string to integer type
- Change SignRequestStatus enum from string-backed to int-backed (0, 1, 2) - Update database migration to use SMALLINT instead of VARCHAR(20) - Update SignRequest entity to use int type for status property - Reduces storage overhead and improves performance - Integer values: 0=draft, 1=able_to_sign, 2=signed Signed-off-by: Vitor Mattos <[email protected]>
1 parent 43804d3 commit 29c8f22

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

lib/Db/SignRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
* @method int getDocmdpLevel()
3636
* @method void setSigningOrder(int $signingOrder)
3737
* @method int getSigningOrder()
38-
* @method void setStatus(string $status)
39-
* @method string getStatus()
38+
* @method void setStatus(int $status)
39+
* @method int getStatus()
4040
*/
4141
class SignRequest extends Entity {
4242
protected ?int $fileId = null;
@@ -49,7 +49,7 @@ class SignRequest extends Entity {
4949
protected ?array $metadata = null;
5050
protected int $docmdpLevel = 0;
5151
protected int $signingOrder = 1;
52-
protected string $status = 'draft';
52+
protected int $status = 0;
5353

5454
public function __construct() {
5555
$this->addType('id', Types::INTEGER);
@@ -63,7 +63,7 @@ public function __construct() {
6363
$this->addType('metadata', Types::JSON);
6464
$this->addType('docmdpLevel', Types::SMALLINT);
6565
$this->addType('signingOrder', Types::INTEGER);
66-
$this->addType('status', Types::STRING);
66+
$this->addType('status', Types::SMALLINT);
6767
}
6868

6969
public function getStatusEnum(): SignRequestStatus {

lib/Db/SignRequestStatus.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
namespace OCA\Libresign\Db;
1010

11-
enum SignRequestStatus: string {
12-
case DRAFT = 'draft';
13-
case ABLE_TO_SIGN = 'able_to_sign';
14-
case SIGNED = 'signed';
11+
enum SignRequestStatus: int {
12+
case DRAFT = 0;
13+
case ABLE_TO_SIGN = 1;
14+
case SIGNED = 2;
1515
}

lib/Migration/Version15000Date20251209000000.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
4141
]);
4242
}
4343
if (!$tableSignRequest->hasColumn('status')) {
44-
$tableSignRequest->addColumn('status', Types::STRING, [
44+
$tableSignRequest->addColumn('status', Types::SMALLINT, [
4545
'notnull' => true,
46-
'length' => 20,
47-
'default' => 'draft',
48-
'comment' => 'Status: draft, able_to_sign, signed',
46+
'default' => 0,
47+
'comment' => 'Status: 0=draft, 1=able_to_sign, 2=signed',
4948
]);
5049
}
5150
}

0 commit comments

Comments
 (0)