mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 10:28:00 +00:00
feat: resolved migration failing
This commit is contained in:
@@ -13,9 +13,10 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp
|
|||||||
await knex(TableName.Project).insert({
|
await knex(TableName.Project).insert({
|
||||||
...project,
|
...project,
|
||||||
type: projectType,
|
type: projectType,
|
||||||
|
defaultProduct: projectType,
|
||||||
// @ts-ignore id is required
|
// @ts-ignore id is required
|
||||||
id: newProjectId,
|
id: newProjectId,
|
||||||
slug: slugify(`${project?.name}-${alphaNumericNanoId(4)}`)
|
slug: slugify(`${project?.name}-${alphaNumericNanoId(8)}`)
|
||||||
});
|
});
|
||||||
|
|
||||||
const customRoleMapping: Record<string, string> = {};
|
const customRoleMapping: Record<string, string> = {};
|
||||||
@@ -198,11 +199,15 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp
|
|||||||
};
|
};
|
||||||
|
|
||||||
const kickOutSecretManagerProject = async (knex: Knex, oldProjectId: string) => {
|
const kickOutSecretManagerProject = async (knex: Knex, oldProjectId: string) => {
|
||||||
const enviroments = await knex(TableName.Environment).where("projectId", oldProjectId).returning("id").first();
|
const secret = await knex(TableName.Secret)
|
||||||
if (enviroments) {
|
.join(TableName.SecretFolder, `${TableName.SecretFolder}.id`, `${TableName.Secret}.folderId`)
|
||||||
|
.join(TableName.Environment, `${TableName.Environment}.id`, `${TableName.SecretFolder}.envId`)
|
||||||
|
.where("projectId", oldProjectId)
|
||||||
|
.returning(`${TableName.Secret}.id`)
|
||||||
|
.first();
|
||||||
|
if (secret) {
|
||||||
const newProjectId = await newProject(knex, oldProjectId, ProjectType.SecretManager);
|
const newProjectId = await newProject(knex, oldProjectId, ProjectType.SecretManager);
|
||||||
await knex(TableName.IntegrationAuth).where("projectId", oldProjectId).update("projectId", newProjectId);
|
await knex(TableName.IntegrationAuth).where("projectId", oldProjectId).update("projectId", newProjectId);
|
||||||
await knex(TableName.ProjectBot).where("projectId", oldProjectId).update("projectId", newProjectId);
|
|
||||||
await knex(TableName.SecretBlindIndex).where("projectId", oldProjectId).update("projectId", newProjectId);
|
await knex(TableName.SecretBlindIndex).where("projectId", oldProjectId).update("projectId", newProjectId);
|
||||||
await knex(TableName.SecretSync).where("projectId", oldProjectId).update("projectId", newProjectId);
|
await knex(TableName.SecretSync).where("projectId", oldProjectId).update("projectId", newProjectId);
|
||||||
await knex(TableName.SecretTag).where("projectId", oldProjectId).update("projectId", newProjectId);
|
await knex(TableName.SecretTag).where("projectId", oldProjectId).update("projectId", newProjectId);
|
||||||
@@ -303,7 +308,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
}
|
}
|
||||||
await knex(TableName.Project).whereIn("id", ids).update("defaultProduct", null);
|
await knex(TableName.Project).whereIn("id", ids).update("defaultProduct", null);
|
||||||
}
|
}
|
||||||
} while (projectsToBeTyped.length > 0);
|
} while (projectsToBeSplit.length > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ProjectType } from "@app/db/schemas";
|
||||||
import {
|
import {
|
||||||
InfisicalProjectTemplate,
|
InfisicalProjectTemplate,
|
||||||
TUnpackedPermission
|
TUnpackedPermission
|
||||||
@@ -5,7 +6,6 @@ import {
|
|||||||
import { getPredefinedRoles } from "@app/services/project-role/project-role-fns";
|
import { getPredefinedRoles } from "@app/services/project-role/project-role-fns";
|
||||||
|
|
||||||
import { ProjectTemplateDefaultEnvironments } from "./project-template-constants";
|
import { ProjectTemplateDefaultEnvironments } from "./project-template-constants";
|
||||||
import { ProjectType } from "@app/db/schemas";
|
|
||||||
|
|
||||||
export const getDefaultProjectTemplate = (orgId: string, type: ProjectType) => ({
|
export const getDefaultProjectTemplate = (orgId: string, type: ProjectType) => ({
|
||||||
id: "b11b49a9-09a9-4443-916a-4246f9ff2c69", // random ID to appease zod
|
id: "b11b49a9-09a9-4443-916a-4246f9ff2c69", // random ID to appease zod
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ForbiddenError, MongoAbility, RawRuleOf } from "@casl/ability";
|
|||||||
import { PackRule, packRules, unpackRules } from "@casl/ability/extra";
|
import { PackRule, packRules, unpackRules } from "@casl/ability/extra";
|
||||||
import { requestContext } from "@fastify/request-context";
|
import { requestContext } from "@fastify/request-context";
|
||||||
|
|
||||||
import { ActionProjectType, ProjectMembershipRole, TableName, TProjects, ProjectType } from "@app/db/schemas";
|
import { ActionProjectType, ProjectMembershipRole, ProjectType, TableName, TProjects } from "@app/db/schemas";
|
||||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
||||||
import {
|
import {
|
||||||
ProjectPermissionActions,
|
ProjectPermissionActions,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ProjectMembershipRole, TOrgRolesUpdate, TProjectRolesInsert, ProjectType } from "@app/db/schemas";
|
import { ProjectMembershipRole, ProjectType, TOrgRolesUpdate, TProjectRolesInsert } from "@app/db/schemas";
|
||||||
import { TProjectPermission } from "@app/lib/types";
|
import { TProjectPermission } from "@app/lib/types";
|
||||||
|
|
||||||
export enum ProjectRoleServiceIdentifierType {
|
export enum ProjectRoleServiceIdentifierType {
|
||||||
|
|||||||
Reference in New Issue
Block a user