Skip to content
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

Scan migration directory only if migrationRun = true. #7474

Open
2 of 21 tasks
virus-warnning opened this issue Mar 16, 2021 · 0 comments
Open
2 of 21 tasks

Scan migration directory only if migrationRun = true. #7474

virus-warnning opened this issue Mar 16, 2021 · 0 comments

Comments

@virus-warnning
Copy link

Feature Description

The Problem

Function createConnection() takes 30 seconds for my ormconfig.
The major reasons of the time consumption are:

  • entities
  • subscribers
  • migrations

When I set migrationRun = false, migration directory was still loaded.

So that I have to switch it myself, like following ...

// entities | subscribers | migrations | elapsed
// ----------------------------------------------
//     X    |      X      |      X     |   0.043
//     O    |      X      |      X     |  19.967
//     X    |      O      |      X     |   0.436
//     X    |      X      |      O     |  10.860
//     O    |      O      |      O     |  31.047

const ormConfig = {
    type: 'mariadb',
    host: process.env.DB_HOST || '127.0.0.1',
    port: process.env.DB_PORT || 3306,
    username: process.env.DB_USER || '****',
    password: process.env.DB_PASS || '****',
    database: process.env.DB_NAME || '****',
    synchronize: (process.env.DB_SYNC == 'true'),
    logging: (process.env.DB_DEBUG == 'true'),
    bigNumberStrings: false,
    entities: [
        `${BASE_DIR}/entities/**/*.{ts,js}`
    ],
    subscribers: [
        `${BASE_DIR}/database/subscriptor/**/*.{ts,js}`
    ],
    cli: {
        'migrationsDir': `${BASE_DIR}/migration`
    }
};

if (process.env.DB_MIGRATION_RUN === 'true') {
    ormConfig.migrationsRun = true;
    ormConfig.migrations = [`${BASE_DIR}/migration/*.{ts,js}`];
}

export default ormConfig;

The Solution

Scan migration directory only if migrationRun = true.

Considered Alternatives

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • 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?

  • 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, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants