Open marshall007 opened 8 years ago
Why do you want to drop the table? To recreate indexes? Can you expand a bit on how you migrate and why you need tableDrop/tableCreate?
@neumino in my particular case the schema and index changes were significant enough to where I needed to pull everything down, drop and recreate the table, modify the data, and insert everything again. The main point is that there should be a way to provision the table regardless of whether it thinks the table has already been initialized or not.
Would you prefer an option to drop and recreate an index if one is found?
@neumino yea that would work too.
Yeah, it's quite tricky to 'recreate' tables (this is useful for testing purposes).
Since the only way to drop a table is with an exposed dash instance (r.db("foo").tableDrop("bar").run()) for some reason, once I create a table back with r.createModel(), I get an incomplete object:
Promise {
_bitField: 1,
_fulfillmentHandler0: [Function: successAdapter],
_rejectionHandler0: [Function: errorAdapter],
_promise0: [Function],
_receiver0: [Circular] }
When using r.createModel() only:
{ [Function: model]
_tableReadyPromise:
Promise {
_bitField: 1,
_fulfillmentHandler0: [Function],
_rejectionHandler0: undefined,
_progressHandler0: undefined,
_promise0:
Promise {
_bitField: 1,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_progressHandler0: undefined,
_promise0: [Object],
_receiver0: undefined,
_settledValue: undefined },
_receiver0: undefined,
_settledValue: undefined },
domain: [Function],
_events: [Function],
_maxListeners: [Function],
setMaxListeners: [Function],
getMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function],
prependListener: [Function],
once: [Function],
prependOnceListener: [Function],
removeListener: [Function],
removeAllListeners: [Function],
listeners: [Function],
listenerCount: [Function],
eventNames: [Function] }
Is there a proper way to do this?
Edit: Are we supposed to use r.table("profile").delete().run() and then r.createModel()?
Currently, the only way to get
thinky
to provision a table schema is by callingModel.ready()
. However, if the table has already been initialized,.ready()
is a no-op. This makes writing migrations scripts which require dropping and recreating a table somewhat of a challenge.