mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
misc: addressed PR comments
This commit is contained in:
@@ -363,6 +363,7 @@ export const snapshotDALFactory = (db: TDbClient) => {
|
|||||||
.join(TableName.Environment, `${TableName.Environment}.id`, `${TableName.SecretFolder}.envId`)
|
.join(TableName.Environment, `${TableName.Environment}.id`, `${TableName.SecretFolder}.envId`)
|
||||||
.join(TableName.Project, `${TableName.Project}.id`, `${TableName.Environment}.projectId`)
|
.join(TableName.Project, `${TableName.Project}.id`, `${TableName.Environment}.projectId`)
|
||||||
.join("snapshot_cte", "snapshot_cte.id", `${TableName.Snapshot}.id`)
|
.join("snapshot_cte", "snapshot_cte.id", `${TableName.Snapshot}.id`)
|
||||||
|
.whereNull(`${TableName.SecretFolder}.parentId`)
|
||||||
.whereRaw(`snapshot_cte.row_num > ${TableName.Project}."pitVersionLimit"`)
|
.whereRaw(`snapshot_cte.row_num > ${TableName.Project}."pitVersionLimit"`)
|
||||||
.delete();
|
.delete();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -434,12 +435,11 @@ export const snapshotDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
// cleanup orphaned snapshots (those that don't belong to an existing folder and folder version)
|
// cleanup orphaned snapshots (those that don't belong to an existing folder and folder version)
|
||||||
await db(TableName.Snapshot)
|
await db(TableName.Snapshot)
|
||||||
.whereNotIn("folderId", function () {
|
.whereNotIn("folderId", (qb) => {
|
||||||
void this.select("folderId")
|
void qb
|
||||||
|
.select("folderId")
|
||||||
.from(TableName.SecretFolderVersion)
|
.from(TableName.SecretFolderVersion)
|
||||||
.union(function () {
|
.union((qb1) => void qb1.select("id").from(TableName.SecretFolder));
|
||||||
void this.select("id").from(TableName.SecretFolder);
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.delete();
|
.delete();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user