Sitelet https://web.archive.org/web/20210822103353/https://github.com/knex/knex/pull/3627
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

Add support for 'CASCADE' in PostgreSQL 'DROP SCHEMA' queries #3627

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

Conversation

@SteveDeWald
Copy link

@SteveDeWald SteveDeWald commented Jan 16, 2020

This commit adds the option of specifying CASCADE to the dropSchema and dropSchemaIfExists methods. Both methods maintain the current defaults.

See the PostgreSQL: DROP SCHEMA documentation for more information.

types/index.d.ts Outdated Show resolved Hide resolved
this.pushQuery(`drop schema ${this.formatter.wrap(schemaName)}`);
SchemaCompiler_PG.prototype.dropSchema = function(schemaName, cascade = false) {
this.pushQuery(
`drop schema ${this.formatter.wrap(schemaName)}${cascade && ' CASCADE'}`

This comment has been minimized.

@maximelkin

maximelkin Jan 27, 2020
Collaborator

does this will work correct for cascade = false?
can you add unit test on this?

cascade = false
) {
this.pushQuery(
`drop schema if exists ${this.formatter.wrap(schemaName)}${cascade &&

This comment has been minimized.

@wubzz

wubzz Jan 28, 2020
Member

This would evaluate to drop schema if exists <tablename>false when cascade is false.

Please change to a ternary-operation.

drop schema if exists ${this.formatter.wrap(schemaName)}${cascade ? ' CASCADE' : ''}
@kibertoad
Copy link
Collaborator

@kibertoad kibertoad commented Dec 8, 2020

@SteveDeWald Do you need any help writing a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants