Skip to content

Commit

Permalink
Merge pull request #8 from gather/tylercampbell/APP-4467/fix-postgres…
Browse files Browse the repository at this point in the history
…-fulltext-index-migration

[APP-4467] fix postgres fulltext index migration
  • Loading branch information
tcampb authored Oct 1, 2019
2 parents f44c5eb + a5e718c commit bd1d5b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gather/typeorm",
"private": true,
"version": "0.4.3",
"version": "0.4.5",
"description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.",
"license": "MIT",
"readmeFilename": "README.md",
Expand Down
6 changes: 4 additions & 2 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
`LEFT JOIN "pg_attribute" "a" ON "a"."attrelid" = "cnst"."conrelid" AND "a"."attnum" = ANY ("cnst"."conkey") ` +
`WHERE "t"."relkind" = 'r' AND (${constraintsCondition})`;

const indicesSql = `SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "i"."relname" AS "constraint_name", "a"."attname" AS "column_name", ` +
const indicesSql = `SELECT "ns"."nspname" AS "table_schema", "pg_am"."amname" AS "access_method", "t"."relname" AS "table_name", "i"."relname" AS "constraint_name", "a"."attname" AS "column_name", ` +
`CASE "ix"."indisunique" WHEN 't' THEN 'TRUE' ELSE'FALSE' END AS "is_unique", pg_get_expr("ix"."indpred", "ix"."indrelid") AS "condition", ` +
`"types"."typname" AS "type_name" ` +
`FROM "pg_class" "t" ` +
Expand All @@ -1388,6 +1388,7 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
`INNER JOIN "pg_class" "i" ON "i"."oid" = "ix"."indexrelid" ` +
`INNER JOIN "pg_type" "types" ON "types"."oid" = "a"."atttypid" ` +
`LEFT JOIN "pg_constraint" "cnst" ON "cnst"."conname" = "i"."relname" ` +
`LEFT JOIN "pg_am" ON "pg_am"."oid" = "i"."relam" ` +
`WHERE "t"."relkind" = 'r' AND "cnst"."contype" IS NULL AND (${constraintsCondition})`;

const foreignKeysCondition = tableNames.map(tableName => {
Expand Down Expand Up @@ -1636,14 +1637,15 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
&& index["table_name"] === constraint["table_name"]
&& index["constraint_name"] === constraint["constraint_name"];
});

return new TableIndex(<TableIndexOptions>{
table: table,
name: constraint["constraint_name"],
columnNames: indices.map(i => i["column_name"]),
isUnique: constraint["is_unique"] === "TRUE",
where: constraint["condition"],
isSpatial: indices.every(i => this.driver.spatialTypes.indexOf(i["type_name"]) >= 0),
isFulltext: false
isFulltext: typeof constraint["access_method"] === "string" && constraint["access_method"] === "gin"
});
});

Expand Down

0 comments on commit bd1d5b4

Please sign in to comment.