You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using custom naming strategy in migrations:generate #1482
Running typeorm migrations:generate generates a migration using the default naming strategy for table and column names. Is it possible to generate the migration using a different naming strategy? I can't find documentation on it.
Alternative approach currently is to manually load file with configuration and append naming strategy. This approach sounds better, maybe we can implement it, since its better and we can't find any better ways yet.
Do you think its worth to do complicate things and support "export" as well? Maybe simply load default from the provided file?
The default export is fine, I think. It's always possible to use it, even if the naming strategy is not already a default export, by defining a new file like
import { SomeNamingStrategy } from './some/path';
export default SomeNamingStrategy;
Reacted by Kampfmoehre, Bogdan Grbatinic, Bryan Müller, Roberto Carraretto, Travis Tarr, Matthew Miller, Luke Czyszczonik, Anton Korniychuk, Taylor James Aucoin, Finlay Beaton and 1 more
Activity
pleerock commentedon Jan 23, 2018
no, there is no such possibility yet. You can contribute if you want btw.
yoz commentedon Jan 23, 2018
Do you think it makes sense to add an ormconfig option that specifies a file to use for naming strategy with a default export? Something like
"namingStrategy": "dist/some_path/naming_strategy.js"(it would have to point to the tsc-compiled js)Alternatively perhaps
for specifying a different export than the default from
naming_strategy.js.pleerock commentedon Jan 31, 2018
yoz we can do that, but wouldn't it be a weird solution?
yoz commentedon Jan 31, 2018
Yes, it would be unusual to say the least. I'm asking before I start writing code (I'm happy to contribute) in case you have a suggested approach.
pleerock commentedon Feb 5, 2018
Alternative approach currently is to manually load file with configuration and append naming strategy. This approach sounds better, maybe we can implement it, since its better and we can't find any better ways yet.
Do you think its worth to do complicate things and support "export" as well? Maybe simply load
defaultfrom the provided file?yoz commentedon Feb 5, 2018
The default export is fine, I think. It's always possible to use it, even if the naming strategy is not already a default export, by defining a new file like
pleerock commentedon Feb 5, 2018
correct, even in the same file. So yes, I think you can implement this functionality if you want.
yoz commentedon Mar 21, 2018
It turns out this is possible when using
ormconfig.js(https://github.com/typeorm/typeorm/blob/master/docs/using-ormconfig.md#loading-from-ormconfigjs) - we canrequire()the naming strategy, e.g.yoz commentedon Mar 21, 2018
I think it's ok to close this.