@@ -1159,13 +1159,15 @@ def __init__(
1159
1159
columns : Sequence [SchemaItem ],
1160
1160
* ,
1161
1161
schema : Optional [str ] = None ,
1162
+ if_not_exists : Optional [bool ] = None ,
1162
1163
_namespace_metadata : Optional [MetaData ] = None ,
1163
1164
_constraints_included : bool = False ,
1164
1165
** kw : Any ,
1165
1166
) -> None :
1166
1167
self .table_name = table_name
1167
1168
self .columns = columns
1168
1169
self .schema = schema
1170
+ self .if_not_exists = if_not_exists
1169
1171
self .info = kw .pop ("info" , {})
1170
1172
self .comment = kw .pop ("comment" , None )
1171
1173
self .prefixes = kw .pop ("prefixes" , None )
@@ -1228,6 +1230,7 @@ def create_table(
1228
1230
operations : Operations ,
1229
1231
table_name : str ,
1230
1232
* columns : SchemaItem ,
1233
+ if_not_exists : Optional [bool ] = None ,
1231
1234
** kw : Any ,
1232
1235
) -> Table :
1233
1236
r"""Issue a "create table" instruction using the current migration
@@ -1300,14 +1303,18 @@ def create_table(
1300
1303
quoting of the schema outside of the default behavior, use
1301
1304
the SQLAlchemy construct
1302
1305
:class:`~sqlalchemy.sql.elements.quoted_name`.
1306
+ :param if_not_exists: If True, adds IF NOT EXISTS operator when
1307
+ creating the new table.
1308
+
1309
+ .. versionadded:: 1.13.3
1303
1310
:param \**kw: Other keyword arguments are passed to the underlying
1304
1311
:class:`sqlalchemy.schema.Table` object created for the command.
1305
1312
1306
1313
:return: the :class:`~sqlalchemy.schema.Table` object corresponding
1307
1314
to the parameters given.
1308
1315
1309
1316
"""
1310
- op = cls (table_name , columns , ** kw )
1317
+ op = cls (table_name , columns , if_not_exists = if_not_exists , ** kw )
1311
1318
return operations .invoke (op )
1312
1319
1313
1320
@@ -1320,11 +1327,13 @@ def __init__(
1320
1327
table_name : str ,
1321
1328
* ,
1322
1329
schema : Optional [str ] = None ,
1330
+ if_exists : Optional [bool ] = None ,
1323
1331
table_kw : Optional [MutableMapping [Any , Any ]] = None ,
1324
1332
_reverse : Optional [CreateTableOp ] = None ,
1325
1333
) -> None :
1326
1334
self .table_name = table_name
1327
1335
self .schema = schema
1336
+ self .if_exists = if_exists
1328
1337
self .table_kw = table_kw or {}
1329
1338
self .comment = self .table_kw .pop ("comment" , None )
1330
1339
self .info = self .table_kw .pop ("info" , None )
@@ -1385,6 +1394,7 @@ def drop_table(
1385
1394
table_name : str ,
1386
1395
* ,
1387
1396
schema : Optional [str ] = None ,
1397
+ if_exists : Optional [bool ] = None ,
1388
1398
** kw : Any ,
1389
1399
) -> None :
1390
1400
r"""Issue a "drop table" instruction using the current
@@ -1400,11 +1410,15 @@ def drop_table(
1400
1410
quoting of the schema outside of the default behavior, use
1401
1411
the SQLAlchemy construct
1402
1412
:class:`~sqlalchemy.sql.elements.quoted_name`.
1413
+ :param if_exists: If True, adds IF EXISTS operator when
1414
+ dropping the table.
1415
+
1416
+ .. versionadded:: 1.13.3
1403
1417
:param \**kw: Other keyword arguments are passed to the underlying
1404
1418
:class:`sqlalchemy.schema.Table` object created for the command.
1405
1419
1406
1420
"""
1407
- op = cls (table_name , schema = schema , table_kw = kw )
1421
+ op = cls (table_name , schema = schema , if_exists = if_exists , table_kw = kw )
1408
1422
operations .invoke (op )
1409
1423
1410
1424
0 commit comments