-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ x ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
Given the following entity:
@Entity()
export class Test {
@PrimaryColumn()
id: number;
@Index("description_index", { fulltext: true })
@Column()
description: string;
}Running a migration with postgres will always generate the following queries, even though no changes are made to the schema:
export class someMigration1598601015234 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`DROP INDEX "description_index"`, undefined);
await queryRunner.query(`CREATE INDEX "description_index" ON "test" ("description") `, undefined);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`DROP INDEX "description_index"`, undefined);
await queryRunner.query(`CREATE INDEX "description_index" ON "test" ("description") `, undefined);
}
}The reason seems to be that postgres does not support fulltext indices, but in RdbmsSchemaBuilder.ts the tableIndex.isFulltext property is checked even for postgres, which makes any fulltext indices give false positives:
typeorm/src/schema-builder/RdbmsSchemaBuilder.ts
Lines 280 to 281 in d1ed572
| if (indexMetadata.isFulltext !== tableIndex.isFulltext) | |
| return true; |
This may be related to #5655 and #5159. It also may occur with other database types.
I intend to submit a PR with a fix shortly.