Skip to content

Support if_exists / if_not_exists on drop_table and create_table operations #1520

@agriffin-grow

Description

@agriffin-grow

Describe the use case
This is similar to #524, which appears to at least be implemented for indexes.

SqlAlchemy already supports these operations on DropTable and CreateTable so this would essentially be a pass-through in a similar manner.

Databases / Backends / Drivers targeted

Postgresql

Example Use
Much like drop_index, I'd expect

op.drop_table('foobar', if_exists=True)

to produce

DROP TABLE IF EXISTS foobar

Additional context
This is just some insurance for edge cases where a migration partially applies due to external circumstances. i.e. a migration containing two drop_table operations could fail after the first succeeds, but then would require some surgery to work again

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    command interfaceuse casenot quite a feature and not quite a bug, something we just didn't think of

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions