|
19 | 19 |
|
20 | 20 | def create_keyspace(name, strategy_class, replication_factor, durable_writes=True, **replication_values): |
21 | 21 | """ |
22 | | - creates a keyspace |
| 22 | + *Deprecated - this will likely be repaced with something specialized per replication strategy.* |
| 23 | + Creates a keyspace |
23 | 24 |
|
24 | | - :param name: name of keyspace to create |
25 | | - :param strategy_class: keyspace replication strategy class |
26 | | - :param replication_factor: keyspace replication factor |
27 | | - :param durable_writes: 1.2 only, write log is bypassed if set to False |
28 | | - :param **replication_values: 1.2 only, additional values to ad to the replication data map |
| 25 | + If the keyspace already exists, it will not be modified. |
| 26 | +
|
| 27 | + **This function should be used with caution, especially in production environments. |
| 28 | + Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
| 29 | +
|
| 30 | + *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
| 31 | +
|
| 32 | + :param str name: name of keyspace to create |
| 33 | + :param str strategy_class: keyspace replication strategy class (:attr:`~.SimpleStrategy` or :attr:`~.NetworkTopologyStrategy` |
| 34 | + :param int replication_factor: keyspace replication factor, used with :attr:`~.SimpleStrategy` |
| 35 | + :param bool durable_writes: Write log is bypassed if set to False |
| 36 | + :param \*\*replication_values: Additional values to ad to the replication options map |
29 | 37 | """ |
30 | 38 | cluster = get_cluster() |
31 | 39 |
|
@@ -54,19 +62,31 @@ def create_keyspace(name, strategy_class, replication_factor, durable_writes=Tru |
54 | 62 |
|
55 | 63 |
|
56 | 64 | def delete_keyspace(name): |
| 65 | + """ |
| 66 | + *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
| 67 | +
|
| 68 | + **This function should be used with caution, especially in production environments. |
| 69 | + Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
| 70 | +
|
| 71 | + Drops a keyspace, if it exists. |
| 72 | +
|
| 73 | + :param str name: name of keyspace to delete |
| 74 | + """ |
57 | 75 | cluster = get_cluster() |
58 | 76 | if name in cluster.metadata.keyspaces: |
59 | 77 | execute("DROP KEYSPACE {}".format(name)) |
60 | 78 |
|
61 | | -def create_table(model): |
62 | | - raise CQLEngineException("create_table is deprecated, please use sync_table") |
63 | | - |
64 | 79 | def sync_table(model): |
65 | 80 | """ |
66 | 81 | Inspects the model and creates / updates the corresponding table and columns. |
67 | 82 |
|
68 | 83 | Note that the attributes removed from the model are not deleted on the database. |
69 | 84 | They become effectively ignored by (will not show up on) the model. |
| 85 | +
|
| 86 | + **This function should be used with caution, especially in production environments. |
| 87 | + Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
| 88 | +
|
| 89 | + *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
70 | 90 | """ |
71 | 91 |
|
72 | 92 | if not issubclass(model, Model): |
@@ -298,11 +318,15 @@ def update_compaction(model): |
298 | 318 | return False |
299 | 319 |
|
300 | 320 |
|
301 | | -def delete_table(model): |
302 | | - raise CQLEngineException("delete_table has been deprecated in favor of drop_table()") |
| 321 | +def drop_table(model): |
| 322 | + """ |
| 323 | + Drops the table indicated by the model, if it exists. |
303 | 324 |
|
| 325 | + **This function should be used with caution, especially in production environments. |
| 326 | + Take care to execute schema modifications in a single context (i.e. not concurrently with other clients).** |
304 | 327 |
|
305 | | -def drop_table(model): |
| 328 | + *There are plans to guard schema-modifying functions with an environment-driven conditional.* |
| 329 | + """ |
306 | 330 |
|
307 | 331 | # don't try to delete non existant tables |
308 | 332 | meta = get_cluster().metadata |
|
0 commit comments