Repository navigation
fix: getPendingMigrations unnecessarily creating migrations table - #11672
Conversation
commit: |
|
I was looking for a way of providing tests for this change, but I could not find any viable example. If you point me to one, I am happy to extend the scope of this PR. There was no need to update documentation. |
WalkthroughRemoves the public Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller (App/CLI)
participant ME as MigrationExecutor
participant QR as QueryRunner
participant DB as Database
Note over ME: getExecutedMigrations()
C->>ME: getExecutedMigrations()
ME->>QR: hasTable(migrationsTable) %% skipped/DB-specific for MongoDB
QR->>DB: Check table existence
DB-->>QR: true/false
alt Table missing (non-MongoDB)
QR-->>ME: false
ME-->>C: []
else Table exists
QR-->>ME: true
ME->>QR: load executed migrations
QR-->>ME: executed list
ME-->>C: executed list
end
Note over ME: getPendingMigrations()
C->>ME: getPendingMigrations()
ME->>ME: allMigrations = this.getMigrations()
ME->>ME: executed = getExecutedMigrations()
alt No executed
ME-->>C: allMigrations
else Some executed
ME->>ME: compute difference (pending)
ME-->>C: pending list
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)src/migration/MigrationExecutor.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🔇 Additional comments (2)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Code Suggestions ✨Latest suggestions up to f888670
Previous suggestionsSuggestions
|
||||||||||||||||||
PR Code Suggestions ✨
|
|||||||||
gioboa
left a comment
There was a problem hiding this comment.
Thanks for your contribution
Is there a way to create tests for this fix?
|
At least some manual testing is required, I agree with gioboa. |
PR Code Suggestions ✨No code suggestions found for the PR. |
|
No, I've completely forgot about it. I hope I'll test it soon. Thanks for reminder |
|
I've tested it and it looks to work as expected. # Before I create a migration
PS C:\home\osa413\GitHub\typeorm-playground> npm start
> [email protected] start
> ts-node src/index.ts
query: SELECT version()
query: SELECT * FROM current_schema()
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
[]
# After I add a migration
PS C:\home\osa413\GitHub\typeorm-playground> npm start
> [email protected] start
> ts-node src/index.ts
query: SELECT version()
query: SELECT * FROM current_schema()
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
[
Migration {
id: undefined,
timestamp: 1767456848332,
name: 'Migration1767456848332',
instance: Migration1767456848332 { name: 'Migration1767456848332' },
transaction: undefined
}
]
PS C:\home\osa413\GitHub\typeorm-playground> |
gioboa
left a comment
There was a problem hiding this comment.
Thanks @pkuczynski 🙏
and @OSA413 for your tests ❤️
Description of change
Fixes #10858
Pull-Request Checklist
masterbranchFixes #00000Summary by CodeRabbit
Bug Fixes
Refactor