Skip to content

Commit bcbb610

Browse files
authored
fix: default for organization id (#3244)
1 parent cc39b2d commit bcbb610

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/entity/Organization.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Entity,
66
Index,
77
OneToMany,
8-
PrimaryColumn,
8+
PrimaryGeneratedColumn,
99
UpdateDateColumn,
1010
} from 'typeorm';
1111
import type { ContentPreferenceOrganization } from './contentPreference/ContentPreferenceOrganization';
@@ -20,8 +20,7 @@ export type OrganizationLink = z.infer<typeof organizationLinksSchema>;
2020
@Entity()
2121
@Index('IDX_organization_subflags_subscriptionid', { synchronize: false })
2222
export class Organization {
23-
@PrimaryColumn({
24-
type: 'text',
23+
@PrimaryGeneratedColumn({
2524
primaryKeyConstraintName: 'PK_organization_organization_id',
2625
})
2726
id: string;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class OrganizationGenerationId1761817857874
4+
implements MigrationInterface
5+
{
6+
name = 'OrganizationGenerationId.ts1761817857874';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
await queryRunner.query(
10+
`ALTER TABLE "organization" ALTER COLUMN "id" SET DEFAULT uuid_generate_v4()`,
11+
);
12+
}
13+
14+
public async down(queryRunner: QueryRunner): Promise<void> {
15+
await queryRunner.query(
16+
`ALTER TABLE "organization" ALTER COLUMN "id" SET DEFAULT NULL`,
17+
);
18+
}
19+
}

0 commit comments

Comments
 (0)