0.3.0 generate migrations path
See original GitHub issueIssue Description
Expected Behavior
When running migration:generate
, I expect the migration generated goes into the migrations
path set in the parameter of the DataSource
constructor.
Basically, I expect it to generate a migration into the path: E:\Projects\Discord Bots\commissions\luigical\src\migrations\<the_migration_file_here>.ts
Actual Behavior
Generating and creating migrations works but it goes into project root folder.
$ yarn typeorm:generate CreateGuildTable
yarn run v1.22.17
$ yarn typeorm:cli migration:generate -d src/ormconfig.ts CreateGuildTable
$ ts-node ./node_modules/typeorm/cli.js migration:generate -d src/ormconfig.ts CreateGuildTable
Migration E:\Projects\Discord Bots\commissions\luigical\CreateGuildTable.ts has been generated successfully.
Done in 9.21s.
Steps to Reproduce
- Use the code below
- Create an entity schema in the path
project\src\entities\table-name.entity.ts
- Run the
migration:generate
command - in my case the scripts I used are:
"typeorm:cli": "ts-node ./node_modules/typeorm/cli.js",
"typeorm:generate": "yarn typeorm:cli migration:generate -d src/ormconfig.ts",
- It does not generate the migration in the correct path
const config: DataSourceOptions = {
type: 'mysql',
host: process.env.MYSQL_HOST,
port: Number(process.env.MYSQL_PORT) || 3306,
username: process.env.MYSQL_USERNAME,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE_NAME,
entities: [__dirname + '\\entities\\**\\*{.ts,.js}'],
migrations: [__dirname + '\\migrations\\**\\*{.ts,.js}'],
cli: {
migrationsDir: 'src\\migrations',
entitiesDir: 'src\\entities'
},
synchronize: false
};
export const dataSource = new DataSource(config);
My Environment
Dependency | Version |
---|---|
Operating System | Windows 10 Home |
Node.js version | 17.3.0 |
Typescript version | 4.5.5 |
TypeORM version | 0.3.0 |
Additional Context
Relevant Database Driver(s)
DB Type | Reproducible |
---|---|
aurora-mysql |
no |
aurora-postgres |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
yes |
nativescript |
no |
oracle |
no |
postgres |
no |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (2 by maintainers)
Top Results From Across the Web
how can i specify the migrations directory for typeorm CLI
You can do this instead: typescript esm: npx typeorm-ts-node-esm migration:create src/database/migration/MigrationFileName where ...
Read more >Doing migrations has changed since type orm 0.3 old cli ...
From what I read on their website you just need to create a class for migrations and use it in a cli command....
Read more >TypeORM v0.3.x Migrations, queries, with NestJS! - YouTube
We'll cover how to create a CRUD API, how to write SQL queries, and finally how to do migrations. 00:00 - Intro 00:21...
Read more >Are you stuck working with TypeORM >= 0.3.0?
Basically, remove path from the command and pass it as argument like this npm run migration:generate-dev src/database/migrations/<filename>.
Read more >Directory error when trying to do migrations using typeorm
No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pleerock absolutely ridiculous change
what the hell? it’s exhausting and not convenient at all. How to configure path once? you should’ve thought about it. And please update documentation, it’s confusing.