summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-08-06 16:10:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-08-06 23:11:54 -0400
commitd8da7f5ac544f3dd853a221faa5fab4ff788e25b (patch)
tree0ec2fa102695a107eb799ed12c4ade60e84a8790 /lib/sqlalchemy/sql/schema.py
parent6a622c636ca5bc55d96b92652fd43b914a77645c (diff)
downloadsqlalchemy-d8da7f5ac544f3dd853a221faa5fab4ff788e25b.tar.gz
Implement checkfirst for Index.create(), Index.drop()
The :meth:`.Index.create` and :meth:`.Index.drop` methods now have a parameter :paramref:`.Index.create.checkfirst`, in the same way as that of :class:`.Table` and :class:`.Sequence`, which when enabled will cause the operation to detect if the index exists (or not) before performing a create or drop operation. Fixes: #527 Change-Id: Idf994bc016359d0ae86cc64ccb20378115cb66d6
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r--lib/sqlalchemy/sql/schema.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py
index 091012896..d9667e445 100644
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -3670,7 +3670,7 @@ class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem):
return self.table.bind
- def create(self, bind=None):
+ def create(self, bind=None, checkfirst=False):
"""Issue a ``CREATE`` statement for this
:class:`.Index`, using the given :class:`.Connectable`
for connectivity.
@@ -3682,10 +3682,10 @@ class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem):
"""
if bind is None:
bind = _bind_or_error(self)
- bind._run_ddl_visitor(ddl.SchemaGenerator, self)
+ bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
return self
- def drop(self, bind=None):
+ def drop(self, bind=None, checkfirst=False):
"""Issue a ``DROP`` statement for this
:class:`.Index`, using the given :class:`.Connectable`
for connectivity.
@@ -3697,7 +3697,7 @@ class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem):
"""
if bind is None:
bind = _bind_or_error(self)
- bind._run_ddl_visitor(ddl.SchemaDropper, self)
+ bind._run_ddl_visitor(ddl.SchemaDropper, self, checkfirst=checkfirst)
def __repr__(self):
return "Index(%s)" % (