Skip to content

Commit

Permalink
chore(server): remove workspace migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
overbit committed Apr 11, 2024
1 parent 42a7a2c commit 61b36f6
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 946 deletions.
66 changes: 0 additions & 66 deletions packages/amplication-server/src/core/block/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,72 +803,6 @@ export class BlockService {
});
}

/**
* @todo REMOVE this after we finish with the custom actions blocks migration
*
* Gets Blocks of types Module and ModuleAction (ONLY) changed since the last resource commit
* @param projectId the resource ID to find changes to
* @param userId the user ID the resource ID relates to
*/
async getChangedBlocksForCustomActionsMigration(
projectId: string,
userId: string
): Promise<BlockPendingChange[]> {
const changedBlocks = await this.prisma.block.findMany({
where: {
lockedByUserId: userId,
// eslint-disable-next-line @typescript-eslint/naming-convention
OR: [
{ blockType: EnumBlockType.Module },
{ blockType: EnumBlockType.ModuleAction },
],
resource: {
deletedAt: null,
project: {
id: projectId,
},
},
},
include: {
lockedByUser: true,
resource: true,
versions: {
orderBy: {
versionNumber: Prisma.SortOrder.desc,
},
/**find the first two versions to decide whether it is an update or a create */
take: 2,
},
},
});

return changedBlocks.map((block) => {
const [lastVersion] = block.versions;
const action = block.deletedAt
? EnumPendingChangeAction.Delete
: block.versions.length > 1
? EnumPendingChangeAction.Update
: EnumPendingChangeAction.Create;

block.versions =
undefined; /**remove the versions data - it will only be returned if explicitly asked by gql */

//prepare name fields for display
if (action === EnumPendingChangeAction.Delete) {
block.displayName = revertDeletedItemName(block.displayName, block.id);
}

return {
originId: block.id,
action: action,
originType: EnumPendingChangeOriginType.Block,
versionNumber: lastVersion.versionNumber + 1,
origin: block,
resource: block.resource,
};
});
}

async getChangedBlocksByCommit(commitId: string): Promise<PendingChange[]> {
const changedBlocks = await this.prisma.block.findMany({
where: {
Expand Down
16 changes: 4 additions & 12 deletions packages/amplication-server/src/core/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,10 @@ export class ProjectService {

let changedEntities: EntityPendingChange[] = [];
let changedBlocks: BlockPendingChange[] = [];
if (skipBuild) {
changedBlocks =
await this.blockService.getChangedBlocksForCustomActionsMigration(
projectId,
userId
);
} else {
[changedEntities, changedBlocks] = await Promise.all([
this.entityService.getChangedEntities(projectId, userId),
this.blockService.getChangedBlocks(projectId, userId),
]);
}
[changedEntities, changedBlocks] = await Promise.all([
this.entityService.getChangedEntities(projectId, userId),
this.blockService.getChangedBlocks(projectId, userId),
]);

/**@todo: consider discarding locked objects that have no actual changes */

Expand Down

This file was deleted.

100 changes: 0 additions & 100 deletions packages/amplication-server/src/core/workspace/workspace.controller.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ProjectModule } from "../project/project.module";
import { BillingModule } from "../billing/billing.module";
import { ModuleModule } from "../module/module.module";
import { ModuleActionModule } from "../moduleAction/moduleAction.module";
import { WorkspaceController } from "./workspace.controller";
import { ResourceModule } from "../resource/resource.module";
import { ModuleDtoModule } from "../moduleDto/moduleDto.module";

Expand All @@ -30,7 +29,7 @@ import { ModuleDtoModule } from "../moduleDto/moduleDto.module";
ModuleActionModule,
ModuleDtoModule,
],
controllers: [WorkspaceController],
controllers: [],
providers: [WorkspaceService, WorkspaceResolver],
exports: [WorkspaceService, WorkspaceResolver],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export class WorkspaceResolver {
currentUser
);

await this.workspaceService.migrateWorkspace(
currentUser.workspace,
currentUser
);

return { ...currentUser.workspace, externalId };
}

Expand Down

0 comments on commit 61b36f6

Please sign in to comment.