orange-dragonfly-orm-model-to-sql 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/mysql.js +5 -3
package/package.json
CHANGED
package/src/mysql.js
CHANGED
|
@@ -119,12 +119,14 @@ class OrangeDragonflyORMSchemaToMySQL {
|
|
|
119
119
|
_convertIndexesToSql(indexes) {
|
|
120
120
|
const queries = []
|
|
121
121
|
for (let [index, indexType] of Object.entries(indexes)) {
|
|
122
|
+
const [table] = index.split('/')[0].split('.')
|
|
123
|
+
const cols = index.split('/').map((v) => v.split('.')[1])
|
|
122
124
|
if (indexType === 'unique') {
|
|
123
|
-
queries.push(`CREATE UNIQUE INDEX uq_${
|
|
125
|
+
queries.push(`CREATE UNIQUE INDEX uq_${table}__${cols.join('__')} ON ${table} (${cols.join(', ')});`)
|
|
124
126
|
} else if (indexType === 'asc') {
|
|
125
|
-
queries.push(`CREATE INDEX ix_${
|
|
127
|
+
queries.push(`CREATE INDEX ix_${table}__${cols.join('__')} ON ${table} (${cols.join(', ')});`)
|
|
126
128
|
} else if (indexType === 'fulltext') {
|
|
127
|
-
queries.push(`CREATE FULLTEXT INDEX ft_${
|
|
129
|
+
queries.push(`CREATE FULLTEXT INDEX ft_${table}__${cols.join('__')} ON ${table} (${cols.join(', ')});`)
|
|
128
130
|
} else {
|
|
129
131
|
throw new Error(`Unknown index type: ${indexType}`)
|
|
130
132
|
}
|