New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.3.0: Naming strategy ignored by migration:generate #8757
Comments
new CLI commands were not documented yet, but for some of the commands like migration:generate -d ./src/my-data-source.ts` Please confirm if you run this commands and specify data source. |
I did specify the datasource, yes. That’s what I meant in the original issue description: I took an existing So: In the So, basically, // 0.2.41 ormconfig.js: connection info and namingStrategy are used
module.exports = {
type: 'postgres',
schema: 'public',
host: "localhost",
username: "postgres",
password: "...",
database: "...",
namingStrategy: new MyNamingStrategy(),
...
}; // 0.3.0 datasource.js: connection info is used, but namingStrategy is ignored
exports.postgres = new DataSource({
type: 'postgres',
schema: 'public',
host: "localhost",
username: "postgres",
password: "...",
database: "...",
// This is not used -- in fact, { namingStrategy: 5 } has the same results!
namingStrategy: new MyNamingStrategy(),
...
}); |
Confirmed. I'll create a PR for this issue. |
fixed by #8764 |
Issue Description
I upgraded TypeORM from 0.2.41 to 0.3.0. I made the necessary changes to get the project building against the updated APIs, and modified my scripts to generate migrations to use the new data source specification rather than the old
ormconfig
. In particular, when it comes to the configuration for CLI commands, I basically changedormconfig.js
module.exports = { type: 'postgres', ... }
toexports.postgres = { type: 'postgres', ... }
, and everything seemed to work.…Except that the migration I generate drops every single constraint and index in my schema and recreates them according to the default naming strategy. It does not appear that the schema builder calls the custom naming strategy at all. From the changelog and documentation, it does not appear to me that the naming strategy options should have changed.
Expected Behavior
When generating migrations, it should call our custom naming strategy and generate constraint names like
dossiers_tenantId_fkey
.Actual Behavior
All the indices, constraints, etc. are renamed to the TypeORM default strategy with uninformative names like
FK_3ce1dd1736f8caad49f49
.Steps to Reproduce
I do not currently have a minimal repro example, sorry.
My Environment
Additional Context
Relevant Database Driver(s)
I have only tested this in Postgres.
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: