trying to add hasMany via metaClass in Bootstrap.groovy does not work
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Sample app
[grail33test-domain-inheritance.zip](https://github.com/grails/grails-core/files/2148314/grail33test-domain-inheritance.zip)
### Steps to Reproduce
Download the attached zip with a sample 3.3.6 grails app. Check in file `GrailsDomainClassMetaClass.groovy`, we are trying to add a default hasMany to each Class that extends `BasexDomainExtended`. We run `GrailsDomainClassMetaClass.extend()` in the Bootstrap.groovy, however this seems to be too late, because the databases have already been created at that point.
### Expected Behaviour
We want too hook into the runtime earlier than Bootstrap.groovy in some way, or have the hasMany static be interpreted even when changes are made after the fact. Something like that? Maybe you guys have a better suggestion.
### Actual Behaviour
In the sample app, 3 tables are created: **Comment**, **Offer** and **Offer_system_flags**. However, the expected behaviour is that the **Offer_system_flags** is not created and instead the **Offer_comments** one is.
### Environment Information
- **Operating System**: Mac OSX 10.13.5
- **Grails Version:** 3.3.6
- **JDK Version:** 1.8.0_144
Contributor guide
Research direction
Download and run the attached sample app, then inspect GrailsDomainClassMetaClass.groovy and Bootstrap.groovy around the call to GrailsDomainClassMetaClass.extend(). Compare the generated tables with the expected result: Offer_comments should be created instead of Offer_system_flags, or the issue should establish an earlier extension point that produces that schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100