Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3b8ab31
wip
prastoin Nov 7, 2025
a37c347
working comand
prastoin Nov 10, 2025
81f6d16
feat(server): continue seeding
prastoin Nov 10, 2025
0e8faf7
feat(server): adding all remaning syncable entities
prastoin Nov 10, 2025
ca03774
feat(server): upgrade command within transaction
prastoin Nov 10, 2025
245a5df
fix
prastoin Nov 10, 2025
81c8013
feat(server): migrate custom entities
prastoin Nov 10, 2025
09ea0ae
fix
prastoin Nov 10, 2025
b5a40fc
feat(server): non nullable universal id and application id
prastoin Nov 10, 2025
8aed9ef
feat(server): upgrade command to handle migration too
prastoin Nov 10, 2025
29777d4
feat(server): create twenty custom workspace application
prastoin Nov 10, 2025
d9e6a33
feat(server): link all upgrade commands
prastoin Nov 10, 2025
d8c1fa4
feat(server): workspace custom app required for workspace entity
prastoin Nov 10, 2025
5c42d68
feat(server): upgrade run migration command once in transaction
prastoin Nov 10, 2025
688f2aa
lint
prastoin Nov 10, 2025
1d44931
feat(server): soft reset me
prastoin Nov 10, 2025
d4b8e0a
refactor(server): sync metadata agent
prastoin Nov 12, 2025
ad155d1
feat(server): reset still broken due to views
prastoin Nov 12, 2025
a38c166
fix(server): view reset
prastoin Nov 12, 2025
d6f1b2c
feat(server): init permissions with appid and universalIdenfitier
prastoin Nov 12, 2025
0ebc69e
fix(server): role creation
prastoin Nov 12, 2025
6f66b44
feat(server): flat application
prastoin Nov 12, 2025
a37d23f
feat(server): object metadata and custom app injection
prastoin Nov 12, 2025
ce51d21
refactor(server): custom app creation application service
prastoin Nov 12, 2025
4b7b64a
fix(server): workspace creation default rol
prastoin Nov 12, 2025
76ef425
lint
prastoin Nov 12, 2025
21ca15a
feat(server): v2 services create operation input transpilation set ap…
prastoin Nov 12, 2025
de917ee
fix(server): remaining tsc errors 1/2
prastoin Nov 12, 2025
812a170
fix(server): remaining tsc errors 1/2
prastoin Nov 12, 2025
11dbb2c
lint
prastoin Nov 12, 2025
d51eacd
fix(server): tsc errors
prastoin Nov 12, 2025
68b280b
fix(server): module dependency injection
prastoin Nov 12, 2025
e5d1114
fix(server): database reset
prastoin Nov 12, 2025
c3a1d99
chore(server): remove seed dashboard view upgrade command
prastoin Nov 12, 2025
9387dd1
feat(server): non nullable applicationid
prastoin Nov 12, 2025
2ba5b34
fix(server): typeorm migrations
prastoin Nov 12, 2025
fe9fd6a
lint
prastoin Nov 12, 2025
1364a56
front codegen
prastoin Nov 12, 2025
f780d14
chore
prastoin Nov 14, 2025
6501b00
refactor(server): relocating files
prastoin Nov 14, 2025
c28af9d
lint
prastoin Nov 14, 2025
894cf36
fix(server): tsc
prastoin Nov 14, 2025
76cade6
chore(server): 1.12 commands
prastoin Nov 17, 2025
55f5fe5
lint
prastoin Nov 17, 2025
ac62f19
feat(server): runner swallow migration error in 1.12
prastoin Nov 17, 2025
dbcd937
feat(server): standard field universal identifier
prastoin Nov 17, 2025
04929bf
workspacefield remove standardId
prastoin Nov 17, 2025
f9fbdb3
workspace entity rename standardId
prastoin Nov 17, 2025
abcf348
lint
prastoin Nov 17, 2025
eea963b
fix(server): restore workspace relation standardId
prastoin Nov 17, 2025
0e7cf32
lint
prastoin Nov 17, 2025
ec39d80
refactor(server): workspace relation universal identifier
prastoin Nov 17, 2025
cd6bde0
refactor(server): more universalidentifier and no more v4 in sync
prastoin Nov 17, 2025
8886269
fixup
prastoin Nov 17, 2025
dc93f28
upgrade commands
prastoin Nov 17, 2025
29478a1
feat(server): prefill core view wiht universal identifier
prastoin Nov 17, 2025
20509da
fix(server): uuids integrity
prastoin Nov 17, 2025
fcf3c71
lint
prastoin Nov 17, 2025
3baa2d6
refactor(server): adapt to new views
prastoin Nov 17, 2025
40fbaa1
lint
prastoin Nov 17, 2025
6a88237
feat(server): distinction between standard id of builting fields and …
prastoin Nov 18, 2025
fff5ec7
refactor(server): universal identifier for builtin fields
prastoin Nov 18, 2025
1e83438
restore base workspace entity standard ids
prastoin Nov 18, 2025
f62365e
refactor(server): attempt to fix sync adding universal id to index an…
prastoin Nov 18, 2025
a0818ab
feat(server): sync metadata fixed
prastoin Nov 18, 2025
a129e4f
wip
prastoin Nov 18, 2025
4ad9e9e
fix(server): sync metadata working
prastoin Nov 18, 2025
26072e5
fix(server): valid uuids for universal identifier views
prastoin Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/twenty-front/src/generated-metadata/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4827,7 +4827,7 @@ export type Workspace = {
viewGroups?: Maybe<Array<CoreViewGroup>>;
viewSorts?: Maybe<Array<CoreViewSort>>;
views?: Maybe<Array<CoreView>>;
workspaceCustomApplicationId?: Maybe<Scalars['String']>;
workspaceCustomApplicationId: Scalars['String'];
workspaceMembersCount?: Maybe<Scalars['Float']>;
workspaceUrls: WorkspaceUrls;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4575,7 +4575,7 @@ export type Workspace = {
viewGroups?: Maybe<Array<CoreViewGroup>>;
viewSorts?: Maybe<Array<CoreViewSort>>;
views?: Maybe<Array<CoreView>>;
workspaceCustomApplicationId?: Maybe<Scalars['String']>;
workspaceCustomApplicationId: Scalars['String'];
workspaceMembersCount?: Maybe<Scalars['Float']>;
workspaceUrls: WorkspaceUrls;
};
Expand Down
1 change: 1 addition & 0 deletions packages/twenty-front/src/testing/mock-data/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const mockCurrentWorkspace: Workspace = {
workspaceMembersCount: 1,
databaseSchema: '',
databaseUrl: '',
workspaceCustomApplicationId: '',
isTwoFactorAuthenticationEnforced: false,
__typename: 'Workspace',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export abstract class UpgradeCommandRunner extends ActiveOrSuspendedWorkspacesMi
this.logger.log('Database migrations completed successfully');
} catch (error) {
this.logger.error('Error running database migrations:', error);
this.logger.log(
this.currentAppVersion.major + '.' + this.currentAppVersion.minor,
);
if (
this.currentAppVersion.major === 1 &&
this.currentAppVersion.minor === 12
) {
return;
}
throw error;
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MigrateAttachmentAuthorToCreatedByCommand } from 'src/database/commands
import { MigrateAttachmentTypeToFileCategoryCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-attachment-type-to-file-category.command';
import { MigrateChannelPartialFullSyncStagesCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-channel-partial-full-sync-stages.command';
import { RegenerateSearchVectorsCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-regenerate-search-vectors.command';
import { SeedDashboardViewCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-seed-dashboard-view.command';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
Expand Down Expand Up @@ -43,7 +42,6 @@ import { WorkspaceCacheStorageModule } from 'src/engine/workspace-cache-storage/
AddWorkflowRunStopStatusesCommand,
CleanOrphanedKanbanAggregateOperationFieldMetadataIdCommand,
MakeSureDashboardNamingAvailableCommand,
SeedDashboardViewCommand,
CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand,
FlushCacheCommand,
],
Expand All @@ -55,7 +53,6 @@ import { WorkspaceCacheStorageModule } from 'src/engine/workspace-cache-storage/
CleanOrphanedKanbanAggregateOperationFieldMetadataIdCommand,
MigrateChannelPartialFullSyncStagesCommand,
MakeSureDashboardNamingAvailableCommand,
SeedDashboardViewCommand,
CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand,
FlushCacheCommand,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/core-modules/application/constants/twenty-standard-applications';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/twenty-standard-applications';

@Command({
name: 'upgrade:1-11:create-twenty-standard-application',
Expand Down Expand Up @@ -64,14 +64,10 @@ export class CreateTwentyStandardApplicationCommand extends ActiveOrSuspendedWor
return;
}

try {
await this.applicationService.createTwentyStandardApplication({
workspaceId,
});
await this.applicationService.createTwentyStandardApplication({
workspaceId,
});

this.logger.log(`Successfully seeded twenty standard`);
} catch (e) {
this.logger.error(`Failed to seed twenty standard`, e);
}
this.logger.log(`Successfully seeded twenty standard`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { CleanOrphanedRoleTargetsCommand } from 'src/database/commands/upgrade-version-command/1-11/1-11-clean-orphaned-role-targets.command';
import { CleanOrphanedUserWorkspacesCommand } from 'src/database/commands/upgrade-version-command/1-11/1-11-clean-orphaned-user-workspaces.command';
import { CreateTwentyStandardApplicationCommand } from 'src/database/commands/upgrade-version-command/1-11/1-11-create-twenty-standard-application.command';
import { AssociateCustomEntitiesToWorkspaceCustomApplicationCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-associate-custom-entities-to-workspace-custom-application.command';
import { AssociateStandardEntitiesToTwentyStandardApplicationCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-associate-standard-entities-to-twenty-standard-application.command';
import { CreateWorkspaceCustomApplicationCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-create-workspace-custom-application.command';
import { MakeSyncableEntitiesUniversalIdentifierAndApplicationIdNonNullableMigration } from 'src/database/commands/upgrade-version-command/1-12/1-12-make-syncable-entities-universal-identifier-and-application-id-non-nullable-migration.command';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
Expand Down Expand Up @@ -34,11 +38,19 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-sc
CleanOrphanedUserWorkspacesCommand,
CleanOrphanedRoleTargetsCommand,
CreateTwentyStandardApplicationCommand,
AssociateStandardEntitiesToTwentyStandardApplicationCommand,
AssociateCustomEntitiesToWorkspaceCustomApplicationCommand,
CreateWorkspaceCustomApplicationCommand,
MakeSyncableEntitiesUniversalIdentifierAndApplicationIdNonNullableMigration,
],
exports: [
CleanOrphanedUserWorkspacesCommand,
CleanOrphanedRoleTargetsCommand,
CreateTwentyStandardApplicationCommand,
AssociateStandardEntitiesToTwentyStandardApplicationCommand,
AssociateCustomEntitiesToWorkspaceCustomApplicationCommand,
CreateWorkspaceCustomApplicationCommand,
MakeSyncableEntitiesUniversalIdentifierAndApplicationIdNonNullableMigration,
],
})
export class V1_11_UpgradeVersionCommandModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';

import { Command } from 'nest-commander';
import {
ALL_METADATA_NAME,
AllMetadataName,
NOT_V2_YET_METADATA_NAME,
NotV2YetAllMetadataName,
} from 'twenty-shared/metadata';
import { isDefined } from 'twenty-shared/utils';
import { DataSource, IsNull, Repository } from 'typeorm';
import { v4 } from 'uuid';

import {
ActiveOrSuspendedWorkspacesMigrationCommandRunner,
type RunOnWorkspaceArgs,
} from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner';
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { ALL_METADATA_ENTITY_BY_METADATA_NAME } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-entity-by-metadata-name.constant';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';

const ALL_METADATA_NAME_TO_MIGRATE = [
...Object.keys(ALL_METADATA_NAME),
...Object.keys(NOT_V2_YET_METADATA_NAME),
] as (AllMetadataName | NotV2YetAllMetadataName)[];

@Command({
name: 'upgrade:1-12:associate-custom-entities-to-workspace-custom-application',
description:
'Will scan all workspace custom entities and associate it to the workspace-custom app and set a universal identifier',
})
export class AssociateCustomEntitiesToWorkspaceCustomApplicationCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
constructor(
@InjectRepository(WorkspaceEntity)
protected readonly workspaceRepository: Repository<WorkspaceEntity>,
protected readonly twentyORMGlobalManager: TwentyORMGlobalManager,
private readonly applicationService: ApplicationService,
@InjectDataSource()
private readonly coreDataSource: DataSource,
) {
super(workspaceRepository, twentyORMGlobalManager);
}

override async runOnWorkspace({
workspaceId,
options,
}: RunOnWorkspaceArgs): Promise<void> {
const workspace = await this.workspaceRepository.findOne({
where: {
id: workspaceId,
},
});

if (!isDefined(workspace)) {
throw new Error(`Could not find workspace ${workspaceId}`);
}

this.logger.log(
`associate-custom-entities-to-custom-workspace-application start ${workspaceId}`,
);

const workspaceCustomApplication = await this.applicationService.findById(
workspace.workspaceCustomApplicationId,
);

if (!isDefined(workspaceCustomApplication)) {
throw new Error(
`Could not find workspace-custom application workspaceId=${workspaceId} applicationId=${workspace.workspaceCustomApplicationId}`,
);
}

const queryRunner = this.coreDataSource.createQueryRunner();

await queryRunner.connect();
await queryRunner.startTransaction();

try {
for (const metadataName of ALL_METADATA_NAME_TO_MIGRATE) {
const currentMetadataEntity =
ALL_METADATA_ENTITY_BY_METADATA_NAME[metadataName];

const metadataEntityRepository = queryRunner.manager.getRepository(
currentMetadataEntity,
);

this.logger.log(`retrieving ${metadataName} entities`);

const customEntities = await metadataEntityRepository.find({
select: {
id: true,
universalIdentifier: true,
applicationId: true,
},
where: {
workspaceId,
applicationId: IsNull(),
},
withDeleted: true,
});

for (const entity of customEntities) {
this.logger.log(`Processing entity id=${entity.id}`);

await metadataEntityRepository.update(entity.id, {
universalIdentifier: entity.universalIdentifier ?? v4(),
applicationId: workspaceCustomApplication.id,
});
}
}

if (!options.dryRun) {
await queryRunner.commitTransaction();
}
} catch (error) {
await queryRunner.rollbackTransaction();
throw error;
} finally {
await queryRunner.release();
}
}
}
Loading
Loading