I tried following this reference and this is now my domain's code:
class SnbrActVector {
long nid
String term
double weight
static mapping = {
version false
nid index:'Nid_Idx'
}
static constraints = {
term(blank:false)
}
}
What I want is to do is to add an index key for the nid column. I dropped the existing table and ran the app again so the table is then recreated. However, when I check for list of indices, I can't see an Nid_Idx, only PRIMARY. Do I have to manually create the index and name it Nid_idx in my mysql database?
Yes, it's working only when using dbCreate = "create".
Let's say I have an empty database and my dbCreate set to "update". In this case index is not created.
Your syntax is correct so it might be another problem or a Grails bug. My advice :
grails create-app) with SnbrActVector as the only domain (grails create-domain...). Copy your code inside.dbCreate = "create-drop" If you see an index created for nid column, then it means that there is problem in your application (you might not have used "create-drop" or something else)
If the index is NOT created => This is a grails bug and you should open a JIRA issue here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With