mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
PIT: fix migration for old projects with no versioning set
This commit is contained in:
@@ -131,9 +131,10 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
for (const batch of batches) {
|
for (const batch of batches) {
|
||||||
i += 1;
|
i += 1;
|
||||||
logger.info(`Processing project batch ${i} of ${batches.length}`);
|
logger.info(`Processing project batch ${i} of ${batches.length}`);
|
||||||
const foldersCommitsList = [];
|
let foldersCommitsList = [];
|
||||||
|
|
||||||
const rootFoldersMap: Record<string, string> = {};
|
const rootFoldersMap: Record<string, string> = {};
|
||||||
|
const envRootFoldersMap: Record<string, string> = {};
|
||||||
|
|
||||||
// Get All Folders for the Project
|
// Get All Folders for the Project
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
@@ -202,11 +203,26 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
foldersCommitsList.push(folderCommit);
|
foldersCommitsList.push(folderCommit);
|
||||||
if (!folder.parentId) {
|
if (!folder.parentId) {
|
||||||
rootFoldersMap[folder.id] = folder.envId;
|
rootFoldersMap[folder.id] = folder.envId;
|
||||||
|
envRootFoldersMap[folder.envId] = folder.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info(`Retrieved folder changes for project batch ${i} of ${batches.length}`);
|
logger.info(`Retrieved folder changes for project batch ${i} of ${batches.length}`);
|
||||||
|
|
||||||
|
const filteredBrokenProjectFolders = [];
|
||||||
|
|
||||||
|
foldersCommitsList = foldersCommitsList.filter((folderCommit) => {
|
||||||
|
if (!envRootFoldersMap[folderCommit.commit.envId]) {
|
||||||
|
filteredBrokenProjectFolders.push(folderCommit.commit.folderId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`Filtered ${filteredBrokenProjectFolders.length} broken project folders: ${JSON.stringify(filteredBrokenProjectFolders)}`
|
||||||
|
);
|
||||||
|
|
||||||
// Insert New Commits in batches of 9000
|
// Insert New Commits in batches of 9000
|
||||||
const newCommits = foldersCommitsList.map((folderCommit) => folderCommit.commit);
|
const newCommits = foldersCommitsList.map((folderCommit) => folderCommit.commit);
|
||||||
const commitBatches = chunkArray(newCommits, 9000);
|
const commitBatches = chunkArray(newCommits, 9000);
|
||||||
|
|||||||
Reference in New Issue
Block a user