Skip to content

Commit

Permalink
Fixing wrong case
Browse files Browse the repository at this point in the history
  • Loading branch information
acrodrig committed Apr 13, 2024
1 parent ece24a3 commit 4cbbb43
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ddl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ export class DDL {
static createFullTextIndex(dbType: string, columns: string[], padWidth = 4, table: string, name = "fulltext"): string {
const pad = "".padEnd(padWidth);

table = table.toLowerCase();
const wrapper = (columns: string[], s = ",", w = false) => columns.map((c) => w ? "COALESCE(" + c + ",'')" : c).join(s);
if (dbType === DB.Provider.MYSQL) return `${pad}CREATE FULLTEXT INDEX ${table}_${name} ON ${table} (${wrapper(columns, ",")});\n`;
if (dbType === DB.Provider.POSTGRES) return `${pad}CREATE INDEX ${table}_${name} ON ${table} USING GIN (TO_TSVECTOR('english', ${wrapper(columns, "||' '||", true)}));`;
if (dbType === DB.Provider.MYSQL) return `${pad}CREATE FULLTEXT INDEX ${table.toLowerCase()}_${name} ON ${table} (${wrapper(columns, ",")});\n`;
if (dbType === DB.Provider.POSTGRES) return `${pad}CREATE INDEX ${table.toLowerCase()}_${name} ON ${table} USING GIN (TO_TSVECTOR('english', ${wrapper(columns, "||' '||", true)}));`;

return "";
}
Expand Down

0 comments on commit 4cbbb43

Please sign in to comment.