Skip to content

Commit 93a81e3

Browse files
authored
Merge pull request #6168 from LibreSign/backport/6166/stable32
[stable32] fix: set default value for signer_order column in migration
2 parents 7aa2c59 + 40d6639 commit 93a81e3

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

lib/Migration/Version15000Date20251209000000.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/**
2020
* Add sequential signing support
2121
* - Adds 'signing_order', 'status', and 'released_at' columns to libresign_sign_request table
22+
* - Adds 'signature_flow' column to libresign_file table
2223
*/
2324
class Version15000Date20251209000000 extends SimpleMigrationStep {
2425
public function __construct(
@@ -81,13 +82,20 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
8182
$qb->executeStatement();
8283

8384
// Second: Update status = 1 for able_to_sign requests (status = 0 AND signed IS NULL AND file.status = 1)
84-
$qb = $this->db->getQueryBuilder();
85-
$qb->update('libresign_sign_request', 'sr')
86-
->innerJoin('sr', 'libresign_file', 'f', $qb->expr()->eq('sr.file_id', 'f.id'))
87-
->set('sr.status', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
88-
->where($qb->expr()->eq('sr.status', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
89-
->andWhere($qb->expr()->isNull('sr.signed'))
90-
->andWhere($qb->expr()->eq('f.status', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT)));
91-
$qb->executeStatement();
85+
$qbSelect = $this->db->getQueryBuilder();
86+
$qbSelect->select('id')
87+
->from('libresign_file')
88+
->where($qbSelect->expr()->eq('status', $qbSelect->createNamedParameter(1, IQueryBuilder::PARAM_INT)));
89+
$fileIds = $qbSelect->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
90+
91+
if (!empty($fileIds)) {
92+
$qbUpdate = $this->db->getQueryBuilder();
93+
$qbUpdate->update('libresign_sign_request')
94+
->set('status', $qbUpdate->createNamedParameter(1, IQueryBuilder::PARAM_INT))
95+
->where($qbUpdate->expr()->eq('status', $qbUpdate->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
96+
->andWhere($qbUpdate->expr()->isNull('signed'))
97+
->andWhere($qbUpdate->expr()->in('file_id', $qbUpdate->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY)));
98+
$qbUpdate->executeStatement();
99+
}
92100
}
93101
}

0 commit comments

Comments
 (0)