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: allow db:drop with force for PostgreSQL >= v13 #1490

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jhony112
Copy link

@jhony112 jhony112 commented Apr 17, 2024

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Description of change

This pull request adds a new --force option to the Sequelize CLI for thedb:dropcommand, enabling forced dropping of PostgreSQL databases on server versions higher than 13. See manual

Motivation:
Currently, the Sequelize CLI lacks the option to force-drop databases on PostgreSQL versions greater than 13. In some scenarios, such as automated testing environments or CI/CD pipelines, it's necessary to forcibly drop databases without prompting for confirmation, especially when the PostgreSQL server version is 13 or above.

Changes Made:

  • Added a new --force option to the db:drop command in the Sequelize CLI.
  • Modified the logic to check database version and add the WITH(FORCE) extra arguments to the SQL if permssible with a fallback to normal drop query .
  • When the --force option is passed and the dialect is PostgreSQL, the CLI now executes the DROP DATABASE statement with the FORCE option, allowing the database to be forcibly dropped without confirmation.
  • Updated the cli docs with usage of flag

Testing:

  • Added unit test to ensure that the --force option behaves as expected on different PostgreSQL server versions.
  • Manually tested the CLI with various PostgreSQL server versions to validate the behaviour of the --force option.
  • This enhancement provides users with a convenient and safe way to force-drop databases when working with PostgreSQL servers on version 13 or higher, improving the overall usability and flexibility of the Sequelize CLI.

@jhony112 jhony112 changed the title feat: allow db:drop with force for PostgreSQL > v13 feat: allow db:drop with force for PostgreSQL >= v13 Apr 17, 2024
@jhony112
Copy link
Author

jhony112 commented Apr 17, 2024

@dpickett @jjulian @sushantdhiman please review 🙏🏽

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.

None yet

1 participant