diff --git a/apps/dokploy/server/api/routers/project.ts b/apps/dokploy/server/api/routers/project.ts index ee353594c..3c9cc23cc 100644 --- a/apps/dokploy/server/api/routers/project.ts +++ b/apps/dokploy/server/api/routers/project.ts @@ -220,30 +220,55 @@ export const projectRouter = createTRPCRouter({ accessedServices, ), with: { domains: true }, + columns: { + applicationId: true, + }, }, mariadb: { where: buildServiceFilter(mariadb.mariadbId, accessedServices), + columns: { + mariadbId: true, + }, }, mongo: { where: buildServiceFilter(mongo.mongoId, accessedServices), + columns: { + mongoId: true, + }, }, mysql: { where: buildServiceFilter(mysql.mysqlId, accessedServices), + columns: { + mysqlId: true, + }, }, postgres: { where: buildServiceFilter( postgres.postgresId, accessedServices, ), + columns: { + postgresId: true, + }, }, redis: { where: buildServiceFilter(redis.redisId, accessedServices), + columns: { + redisId: true, + }, }, compose: { where: buildServiceFilter(compose.composeId, accessedServices), with: { domains: true }, + columns: { + composeId: true, + }, }, }, + columns: { + environmentId: true, + isDefault: true, + }, }, }, orderBy: desc(projects.createdAt), @@ -258,18 +283,48 @@ export const projectRouter = createTRPCRouter({ with: { domains: true, }, + columns: { + applicationId: true, + }, + }, + mariadb: { + columns: { + mariadbId: true, + }, + }, + mongo: { + columns: { + mongoId: true, + }, + }, + mysql: { + columns: { + mysqlId: true, + }, + }, + postgres: { + columns: { + postgresId: true, + }, + }, + redis: { + columns: { + redisId: true, + }, }, - mariadb: true, - mongo: true, - mysql: true, - postgres: true, - redis: true, compose: { with: { domains: true, }, + columns: { + composeId: true, + }, }, }, + columns: { + environmentId: true, + isDefault: true, + }, }, }, where: eq(projects.organizationId, ctx.session.activeOrganizationId), diff --git a/packages/server/src/services/environment.ts b/packages/server/src/services/environment.ts index d37e7b789..bf4920193 100644 --- a/packages/server/src/services/environment.ts +++ b/packages/server/src/services/environment.ts @@ -34,42 +34,134 @@ export const createEnvironment = async ( export const findEnvironmentById = async (environmentId: string) => { const environment = await db.query.environments.findFirst({ where: eq(environments.environmentId, environmentId), + columns: { + name: true, + description: true, + environmentId: true, + isDefault: true, + projectId: true, + env: true, + }, with: { applications: { with: { - deployments: true, - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + name: true, + applicationId: true, + createdAt: true, + applicationStatus: true, + description: true, + serverId: true, }, }, mariadb: { with: { - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + mariadbId: true, + name: true, + createdAt: true, + applicationStatus: true, + description: true, + serverId: true, }, }, mongo: { with: { - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + mongoId: true, + name: true, + createdAt: true, + applicationStatus: true, + description: true, + serverId: true, }, }, mysql: { with: { server: true, }, + columns: { + mysqlId: true, + name: true, + createdAt: true, + applicationStatus: true, + description: true, + serverId: true, + }, }, postgres: { with: { - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + postgresId: true, + name: true, + description: true, + createdAt: true, + applicationStatus: true, + serverId: true, }, }, redis: { with: { - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + redisId: true, + name: true, + createdAt: true, + applicationStatus: true, + description: true, + serverId: true, }, }, compose: { with: { - deployments: true, - server: true, + server: { + columns: { + name: true, + serverId: true, + }, + }, + }, + columns: { + composeId: true, + name: true, + createdAt: true, + composeStatus: true, + description: true, + serverId: true, }, }, project: true, @@ -98,6 +190,12 @@ export const findEnvironmentsByProjectId = async (projectId: string) => { compose: true, project: true, }, + columns: { + name: true, + description: true, + environmentId: true, + isDefault: true, + }, }); return projectEnvironments; }; @@ -169,6 +267,7 @@ export const duplicateEnvironment = async ( name: input.name, description: input.description || originalEnvironment.description, projectId: originalEnvironment.projectId, + env: originalEnvironment.env, }) .returning() .then((value) => value[0]);