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

Pending migration alert during app startup #1329

Open
4 of 8 tasks
svkrclg opened this issue Jun 27, 2023 · 6 comments
Open
4 of 8 tasks

Pending migration alert during app startup #1329

svkrclg opened this issue Jun 27, 2023 · 6 comments

Comments

@svkrclg
Copy link

svkrclg commented Jun 27, 2023

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Feature Description

Pending migration (if any) alert during app startup.

Describe the feature you'd like to see implemented

I checked sequelize docs but didn't find any way of getting notified if there is pending migration left. This could be useful in many ways when there are multiple devs working on the project.
During app startup, upon initialization of sequelize we should check for current migrations in DB and existing migrations in the migrations folder, and upon any mismatch we throw a non-zero exit and stop the application with a message. All this can be configurable IMO.

Describe why you would like this feature to be added to Sequelize

We can have an external npm package for this, but make sense to have it here. Also, this feature is available in Ruby on Rails ActiveRecord gem.

Is this feature dialect-specific?

  • No. This feature is relevant to Sequelize as a whole.
  • Yes. This feature only applies to the following dialect(s):

Would you be 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 will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.

Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.

@ephys ephys transferred this issue from sequelize/sequelize Jun 27, 2023
@ephys
Copy link
Member

ephys commented Jun 27, 2023

Moved to the CLI repo because the core library is not aware of the migrations (it is entirely a cli concern). We could definitely add a cli subcommand that checks this, that you could use in your start command

@ephys
Copy link
Member

ephys commented Jun 27, 2023

This is strongly related to the --dry-run flag: #219

@svkrclg
Copy link
Author

svkrclg commented Jun 29, 2023

No, IMO. I'm talking about a logic that will terminate the app during bootup when there is a pending migration.

@ephys
Copy link
Member

ephys commented Jun 29, 2023

This is something you'll need to run before you boot your app and decide whether the app may boot based on the exit status of the cli. The core library, which you use in your app, has no knowledge of migrations. This is because you can use any migration tool, you're not limited to the sequelize cli.

Alternatively you can use child_process.exec to run the relevant cli command from inside your app.

Depending on how --dry-run is designed, it could cover both use cases. I did say "strongly related", not "the same as", we could also decide to go for a --check-no-pending-migrations flag or similar.

@svkrclg
Copy link
Author

svkrclg commented Jul 8, 2023

Thanks for explanation and it make sense now. Should I start working on this feature?

@ephys
Copy link
Member

ephys commented Jul 21, 2023

We're actually planning on rewriting the CLI from scratch, so it's unlikely that we'll do much on this repository anymore

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