-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Labels
Description
Issue Description
Expected Behavior
- First Test1.sql is generating with primary key and without unique index. Because unique index is not needed for primary key column.
- Second Test2.sql is do not generating changes by companyId that is not needed, because companyId is primary key.
Actual Behavior
- First Test1.sql is generating primary key without unique index.
- Second Test2.sql is generating unique index by companyId column that is not needed, because companyId is primary key.
Steps to Reproduce
Database: PostgreSQL
- Create Company and CompanyReport tables with entities.
@Entity()
export class Company {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToOne(() => CompanyReport, (report) => report.company)
report: CompanyReport | null;
}
@Entity()
export class CompanyReport {
@PrimaryColumn()
companyId: string;
@OneToOne(
() => Company,
(company) => company.report,
{ nullable: false, onDelete: 'CASCADE' },
)
@JoinColumn({
name: 'companyId',
})
company: Company;
}- Run typeorm migration:generate -c default -n Test1.
- Run typeorm migration:generate -c default -n Test2.
My Environment
| Dependency | Version |
| Database | PostgreSQL 12.9 |
| Node.js version | 14.16.0 |
| Typescript version | 4.4.3 |
| TypeORM version | 0.2.41 |
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
postgres |
yes |