Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
acrodrig committed Apr 13, 2024
1 parent 4cbbb43 commit 853b526
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ddl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export class DDL {
const pad = "".padEnd(padWidth);

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.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)}));`;
const tlc = table.toLowerCase();
if (dbType === DB.Provider.MYSQL) return `${pad}CREATE FULLTEXT INDEX ${tlc}_${name} ON ${table} (${wrapper(columns, ",")});\n`;
if (dbType === DB.Provider.POSTGRES) return `${pad}CREATE INDEX ${tlc}_${name} ON ${table} USING GIN (TO_TSVECTOR('english', ${wrapper(columns, "||' '||", true)}));`;

return "";
}
Expand Down

0 comments on commit 853b526

Please sign in to comment.