diff --git a/packages/twenty-server/src/database/commands/upgrade-version/0-34/0-34-generate-subdomain.command.ts b/packages/twenty-server/src/database/commands/upgrade-version/0-34/0-34-generate-subdomain.command.ts index 4656de25bb..05ab263029 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version/0-34/0-34-generate-subdomain.command.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version/0-34/0-34-generate-subdomain.command.ts @@ -27,6 +27,7 @@ export class GenerateDefaultSubdomainCommand extends ActiveWorkspacesCommandRunn private generatePayloadForQuery({ id, subdomain, + // @ts-expect-error - this property doesn't exist anymore domainName, displayName, }: Workspace) { diff --git a/packages/twenty-server/src/database/typeorm-seeds/core/workspaces.ts b/packages/twenty-server/src/database/typeorm-seeds/core/workspaces.ts index d3dceb8a88..e28561deb7 100644 --- a/packages/twenty-server/src/database/typeorm-seeds/core/workspaces.ts +++ b/packages/twenty-server/src/database/typeorm-seeds/core/workspaces.ts @@ -20,7 +20,6 @@ export const seedWorkspaces = async ( Workspace, | 'id' | 'displayName' - | 'domainName' | 'inviteHash' | 'logo' | 'subdomain' @@ -30,7 +29,6 @@ export const seedWorkspaces = async ( [SEED_APPLE_WORKSPACE_ID]: { id: workspaceId, displayName: 'Apple', - domainName: 'apple.dev', subdomain: 'apple', inviteHash: 'apple.dev-invite-hash', logo: 'https://twentyhq.github.io/placeholder-images/workspaces/apple-logo.png', @@ -39,7 +37,6 @@ export const seedWorkspaces = async ( [SEED_ACME_WORKSPACE_ID]: { id: workspaceId, displayName: 'Acme', - domainName: 'acme.dev', subdomain: 'acme', inviteHash: 'acme.dev-invite-hash', logo: 'https://logos-world.net/wp-content/uploads/2022/05/Acme-Logo-700x394.png', diff --git a/packages/twenty-server/src/database/typeorm/core/migrations/common/1734538670589-add-hostname-to-workspace.ts b/packages/twenty-server/src/database/typeorm/core/migrations/common/1734538670589-add-hostname-to-workspace.ts new file mode 100644 index 0000000000..bfe4bc4f39 --- /dev/null +++ b/packages/twenty-server/src/database/typeorm/core/migrations/common/1734538670589-add-hostname-to-workspace.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddHostnameToWorkspace1734538670589 implements MigrationInterface { + name = 'AddHostnameToWorkspace1734538670589'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "core"."workspace" RENAME COLUMN "domainName" TO "hostname"`, + ); + await queryRunner.query( + `ALTER TABLE "core"."workspace" ADD CONSTRAINT "UQ_e6fa363bdaf45cbf8ce97bcebf0" UNIQUE ("hostname")`, + ); + await queryRunner.query(`UPDATE "core"."workspace" SET "hostname" = NULL`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "core"."workspace" DROP CONSTRAINT "UQ_e6fa363bdaf45cbf8ce97bcebf0"`, + ); + await queryRunner.query( + `ALTER TABLE "core"."workspace" RENAME COLUMN "hostname" TO "domainName"`, + ); + } +} diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts index 8ca5c2329c..b1e2d6ad63 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts @@ -314,7 +314,6 @@ export class SignInUpService { const workspaceToCreate = this.workspaceRepository.create({ subdomain: await this.domainManagerService.generateSubdomain(), displayName: '', - domainName: '', inviteHash: v4(), activationStatus: WorkspaceActivationStatus.PENDING_CREATION, }); diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts index b2a98f9338..e28c4b20a1 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts @@ -51,11 +51,6 @@ export class Workspace { @PrimaryGeneratedColumn('uuid') id: string; - // @deprecated. Use hostname field - // @Field({ nullable: true }) - // @Column({ nullable: true }) - // domainName?: string; - @Field({ nullable: true }) @Column({ nullable: true }) displayName?: string; @@ -148,8 +143,8 @@ export class Workspace { @Column() subdomain: string; - @Field() - @Column({ unique: true }) + @Field({ nullable: true }) + @Column({ unique: true, nullable: true }) hostname: string; @Field() diff --git a/packages/twenty-website/src/content/developers/backend-development/server-commands.mdx b/packages/twenty-website/src/content/developers/backend-development/server-commands.mdx index 424ef37a36..1b8fe71e9a 100644 --- a/packages/twenty-website/src/content/developers/backend-development/server-commands.mdx +++ b/packages/twenty-website/src/content/developers/backend-development/server-commands.mdx @@ -48,7 +48,7 @@ npx nx run twenty-server:database:reset #### For objects in Core/Metadata schemas (TypeORM) ```bash -npx nx run twenty-server:typeorm --migration:generate src/database/typeorm/metadata/migrations/nameOfYourMigration -d src/database/typeorm/metadata/metadata.datasource.ts # replace by core data source if necessary +npx nx run twenty-server:typeorm -- migration:generate src/database/typeorm/metadata/migrations/nameOfYourMigration -d src/database/typeorm/metadata/metadata.datasource.ts # replace by core data source if necessary ``` #### For Workspace objects