Skip to content

Postgres, migrations: Fulltext indices continually dropped & re-created #6633

@michaelbromley

Description

@michaelbromley

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions