add migration

This commit is contained in:
Antoine Moreaux 2024-12-18 17:27:15 +01:00
parent 3fa8df1fc5
commit 1256151647
6 changed files with 28 additions and 12 deletions

View File

@ -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) {

View File

@ -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',

View File

@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddHostnameToWorkspace1734538670589 implements MigrationInterface {
name = 'AddHostnameToWorkspace1734538670589';
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
await queryRunner.query(
`ALTER TABLE "core"."workspace" DROP CONSTRAINT "UQ_e6fa363bdaf45cbf8ce97bcebf0"`,
);
await queryRunner.query(
`ALTER TABLE "core"."workspace" RENAME COLUMN "hostname" TO "domainName"`,
);
}
}

View File

@ -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,
});

View File

@ -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()