typeorm / typeorm

ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
http://typeorm.io
MIT License
34k stars 6.27k forks source link

Cannot show any migrations using cli #9769

Open thinkong opened 1 year ago

thinkong commented 1 year ago

Issue description

yarn typeorm migration:show -d ./src/data-sources.ts won't show anything

Expected Behavior

It should show me a list of migrations

Actual Behavior

doesn't show me any of the migrations i have generated

Steps to reproduce

From empty folder.. follow the instructions in the quickstart guide.. Except I used mysql and yarn.

Run yarn typeorm migration:generate -d .\src\data-source.ts init move the created migration file to migration folder

change data-source to following.

import "reflect-metadata"
import { DataSource } from "typeorm"
import { User } from "./entity/User"

export const AppDataSource = new DataSource({
    type: "mysql",
    host: "localhost",
    port: 3306,
    username: "test",
    password: "test",
    database: "test",
    synchronize: true,
    logging: false,
    entities: [User],
    migrations: [join(__dirname, 'migration/*{.ts,.js}')],
    subscribers: [],
})

Then run migration:show yarn typeorm migration:show -d .\src\data-source.ts

It shows nothing..

My Environment

Dependency Version
Operating System Windows 11
Node.js version 16.18.0
Typescript version 4.5.2
TypeORM version 0.3.12

Also.. my mysql environment is on aws using aurora-mysql

Additional Context

No response

Relevant Database Driver(s)

Are you willing to resolve this issue by submitting a Pull Request?

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Mauro-Domingues commented 1 year ago

It started since latest version: ^0.3.12 Migration:generate and also migration:run aren't working

Captura de tela 2023-02-10 195252

image

cduff commented 1 year ago

Also reported as issue https://github.com/typeorm/typeorm/issues/9785?

May only occur when running on Windows machines? I'm able to work around by executing migration commands inside a Docker container.

cduff commented 1 year ago

Could be related to update of glob dependency from ^7.2.0 to ^8.1.0.

rajansharma3097 commented 1 year ago

@cduff I'm also getting the same issue. Could you please help to resolve this issue asap?

I'm using the latest TypeOrm version: ^0.3.12 Database: MySQL Node Version: v18.14.0 migration:generate and also migration:run aren't working

image

image

alumni commented 1 year ago

The issue is in the way TypeORM calls glob.sync. Since v8, \ is not allowed by default as path separator, which is the path separator on Windows.

Check the changelog for glob 8.1.0, they made a workaround to allow v7 behavior to continue working. I also made a quick fix for jorgebodega/typeorm-seeding#184 (in a slightly different way).

MarcioJrios commented 1 year ago

I'm migrating a project from typeorm 0.2 to 0.3 and started facing the same issue here.

Mauro-Domingues commented 1 year ago

I'm migrating a project from typeorm 0.2 to 0.3 and started facing the same issue here.

While the problem is not solved, revert your version to 0.3.11. Actually working perfectlly.

alumni commented 1 year ago

Duplicate of #9766

rajansharma3097 commented 1 year ago

I'm migrating a project from typeorm 0.2 to 0.3 and started facing the same issue here.

While the problem is not solved, revert your version to 0.3.11. Actually working perfectlly.

@Mauro-Domingues Could you please share the example application with this change? Because I have tried the suggested change and it's not working. Also, if possible, could you please share your package.json and data-source.ts file?

darwinsubramaniam commented 1 year ago

The issue is in the 0.3.12 version , reverting to 0.3.11 working as per expected

rajansharma3097 commented 1 year ago

The issue is in the 0.3.12 version , reverting to 0.3.11 working as per expected

@darwinsubramaniam I have tried this, but it's not working as expected. Now I'm not getting any error, but not getting anything either on running the command. If possible, could you please share your package.json and data-source.ts files?

sujesh-t commented 6 months ago

Is this fixed ? I am facing issues in v0.3.20

Mauro-Domingues commented 6 months ago

Is this fixed ? I am facing issues in v0.3.20

i can assure v0.3.15 is working correctly, i am currently on that version since they solved this.

alumni commented 6 months ago

Also working correctly in 0.3.20. This issue should've been closed already (it was introduced by the glob upgrade but worked around by normalizing paths in TypeORM).

@sujesh-t I would open a new ticket with some reproducible example.