Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server): remove workspace migration scripts #8315

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we confident that we finished with the old migration and we no longer need this lazy migration?

currentUser.workspace,
currentUser
);

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

Expand Down