Please make sure to review and check all of these items:
[x] 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?
[x] Have you added new tests to prevent regressions?
[x] 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.
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
pass with this change (including linting)?Description of change
This pull request adds a new --force option to the Sequelize CLI for the
db:drop
command, enabling forced dropping of PostgreSQL databases on server versions higher than 13. See manualMotivation: 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:
db:drop
command in the Sequelize CLI.WITH(FORCE)
extra arguments to the SQL if permssible with a fallback to normal drop query .--force
option is passed and the dialect is PostgreSQL, the CLI now executes theDROP DATABASE
statement with theFORCE
option, allowing the database to be forcibly dropped without confirmation.Testing:
--force
option behaves as expected on different PostgreSQL server versions.--force
option.