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

feat: add fake migrations running and reverting #8976

Merged
merged 5 commits into from
Aug 25, 2022

Conversation

ahmedosama94
Copy link
Contributor

@ahmedosama94 ahmedosama94 commented May 8, 2022

Added a cli option to fake-run or fake-revert a migration, adding to the
executed migrations table, but not actually running it. This feature is
useful for when migrations are added after the fact or for
interoperability between applications which are desired to each keep
a consistent migration history

Closes: #6195

Description of change

Extended cli migration:run and migration:revert to have a --fake (alias -f) option, to fake run migrations, for migrations added after the fact (similar to Django's python manage.py migrate --fake). Detailed description in linked issue.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change ---> SAP skipped as tests threw errors that blocked all tests from being run. Some tests where also failing before the update as well (schema builder > create table), these ones do still fail (at least on my end).
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

Added a cli option to fake-run or fake-revert a migration, adding to the
executed migrations table, but not actually running it. This feature is
useful for when migrations are added after the fact or for
interoperability between applications which are desired to each keep
a consistent migration history

Closes: typeorm#6195
@@ -23,6 +23,7 @@ export class MigrationExecutor {
* each: each migration is run in a separate transaction
*/
transaction: "all" | "none" | "each" = "all"
fake: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a description about this feature here as well?

before(async () => {
dataSources = await createTestingConnections({
entities: [__dirname + "/entity/*{.js,.ts}"],
enabledDrivers: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you explicitly specified all the drivers? it's not scalable, if you want to ignore only one or two drivers - better to add checks in the tests like if (dataSource.options.type === "mongodb") return

@pleerock
Copy link
Member

Thank you for contribution! Can you please address the given comments and resolve the conflicts before I can merge it? Thank you.

@AlexMesser AlexMesser merged commit 340ab67 into typeorm:master Aug 25, 2022
@AlexMesser
Copy link
Collaborator

thank you for contribution!

nordinh pushed a commit to nordinh/typeorm that referenced this pull request Aug 29, 2022
* feat: add fake migrations running and reverting

Added a cli option to fake-run or fake-revert a migration, adding to the
executed migrations table, but not actually running it. This feature is
useful for when migrations are added after the fact or for
interoperability between applications which are desired to each keep
a consistent migration history

Closes: typeorm#6195

* changed enabled drivers in test

* added docs to the property

* fixed lint issue

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: fake migrations for existing tables
3 participants