(index: IndexDef, table: DatabaseTable, createPrimary = false)
| 1084 | } |
| 1085 | |
| 1086 | createIndex(index: IndexDef, table: DatabaseTable, createPrimary = false): string { |
| 1087 | if (index.primary && !createPrimary) { |
| 1088 | return ''; |
| 1089 | } |
| 1090 | |
| 1091 | if (index.expression) { |
| 1092 | return index.expression; |
| 1093 | } |
| 1094 | |
| 1095 | const columns = index.columnNames.map(c => this.quote(c)).join(', '); |
| 1096 | const defer = index.deferMode ? ` deferrable initially ${index.deferMode}` : ''; |
| 1097 | |
| 1098 | if (index.primary) { |
| 1099 | const keyName = this.hasNonDefaultPrimaryKeyName(table) ? `constraint ${index.keyName} ` : ''; |
| 1100 | return `alter table ${table.getQuotedName()} add ${keyName}primary key (${columns})${defer}`; |
| 1101 | } |
| 1102 | |
| 1103 | if (index.type === 'fulltext') { |
| 1104 | const columns = index.columnNames.map(name => ({ name, type: table.getColumn(name)!.type })); |
| 1105 | |
| 1106 | if (this.platform.supportsCreatingFullTextIndex()) { |
| 1107 | return this.platform.getFullTextIndexExpression(index.keyName, table.schema, table.name, columns); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | return this.getCreateIndexSQL(table.getShortestName(), index); |
| 1112 | } |
| 1113 | |
| 1114 | createCheck(table: DatabaseTable, check: CheckDef): string { |
| 1115 | const expression = check.expression as string; |
nothing calls this directly
no test coverage detected