Drops the table indicated by the model, if it exists. If `keyspaces` is specified, the table will be dropped for all specified keyspaces. Note that the `Model.__keyspace__` is ignored in that case. If `connections` is specified, the table will be synched for all specified connections.
(model, keyspaces=None, connections=None)
| 500 | |
| 501 | |
| 502 | def drop_table(model, keyspaces=None, connections=None): |
| 503 | """ |
| 504 | Drops the table indicated by the model, if it exists. |
| 505 | |
| 506 | If `keyspaces` is specified, the table will be dropped for all specified keyspaces. Note that the `Model.__keyspace__` is ignored in that case. |
| 507 | |
| 508 | If `connections` is specified, the table will be synched for all specified connections. Note that the `Model.__connection__` is ignored in that case. |
| 509 | If not specified, it will try to get the connection from the Model. |
| 510 | |
| 511 | |
| 512 | **This function should be used with caution, especially in production environments. |
| 513 | Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
| 514 | |
| 515 | *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
| 516 | """ |
| 517 | |
| 518 | context = _get_context(keyspaces, connections) |
| 519 | for connection, keyspace in context: |
| 520 | with query.ContextQuery(model, keyspace=keyspace) as m: |
| 521 | _drop_table(m, connection=connection) |
| 522 | |
| 523 | |
| 524 | def _drop_table(model, connection=None): |