- 
                Notifications
    
You must be signed in to change notification settings  - Fork 182
 
Description
Steps to reproduce
- Create the model, repository, and detasource with 
@property({type: 'string', mysql: {index: {kind: "FULLTEXT"}}})on model. npm run migrateon cli.- It should make FULLTEXT INDEX, however it isn't made on MySQL.
 
This is example of a model.
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {Entity, model, property} from '@loopback/repository';
@model()
export class Todo extends Entity {
  @property({
    type: 'number',
    id: true,
    generated: false,
  })
  id?: number;
  @property({
    type: 'string',
    required: true,
    // Not work for index creation
    mysql: {
      index: {
        kind: 'FULLTEXT',
      },
    },
  })
  title: string;
  @property({
    type: 'string',
    // work for index creation. but it is diffrent by README
    index: {
      kind: 'FULLTEXT',
      // also it can `unique: true` in here, not mysql.index.unique...
    },
  })
  desc?: string;
  constructor(data?: Partial<Todo>) {
    super(data);
  }
}
export interface TodoRelations {
  // describe navigational properties here
}
export type TodoWithRelations = Todo & TodoRelations;Current Behavior
@property.mysql.index is not work.
But, I see work with @property.index.
Expected Behavior
We can replace @property.mysql.index with @property.index on README.
loopback-connector-mysql/README.md
Lines 535 to 545 in f8f40a1
| class Post { | |
| @property({ | |
| type: 'string', | |
| mysql: { | |
| index: { | |
| kind: 'FULLTEXT' | |
| } | |
| }, | |
| }) | |
| content: string; | |
| } | 
Or,
Fix the prop.index to prop.mysql.index and m.properties[propName].index; to m.properties[propName].mysql.index; on migration.js.
loopback-connector-mysql/lib/migration.js
Line 661 in f8f40a1
| const i = prop && prop.index; | 
loopback-connector-mysql/lib/migration.js
Line 361 in f8f40a1
| const i = m.properties[propName].index; | 
Link to reproduction sandbox
Additional information
the index creation function are already exist. But it is different config written by README.
I don't know that either is correct.
Related Issues
See Reporting Issues for more tips on writing good issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status