levansuper
levansuper

Reputation: 1033

TypeORM generates migrations with db name

I need to generate the migration with TypeORM and it does it with this command:

npm run typeorm migration:generate -n test

but the problem is that it generates the migrations that include the DB name

 await queryRunner.query(`CREATE TABLE \`testdb\`.\`lbs_user\` (\`id\` char(36) NOT ...

can I somehow remove "testdb"?

this is the config file

{
    "type": "mysql",
    "host": conf.env.migrationDatabase.host,
    "port": conf.env.migrationDatabase.port,
    "username": conf.env.migrationDatabase.username,
    "password": conf.env.migrationDatabase.password,
    "database": conf.env.migrationDatabase.dbName, //the database name is -> testdb
    "entityPrefix": conf.env.database.entityPrefix,
    "synchronize": false,  
    "migrationsTableName": `${conf.env.database.entityPrefix}migrations`,
    "entities": ["src/modules/db/entities/**/*.entity.ts"],
    "migrations": ["src/migrations/**/*.ts"],
    "cli": {      
        "migrationsDir": "src/migrations",
    }
}

Entity declaration:

@Entity("user")
export class UserEntity {
    @PrimaryColumn({ generated: "uuid" })
    id: string;

    @Column({
        unique: true,
    })
    email: string;

Upvotes: 0

Views: 1619

Answers (1)

levansuper
levansuper

Reputation: 1033

In the end, it appeared that I was using an old version of typeorm. upgraded to version 0.2.38 and no database name is generated anymore.

Upvotes: 1

Related Questions