[ckan-dev] Creating tables for plugin models

Alice Heaton a.heaton at nhm.ac.uk
Thu Jun 19 09:19:02 UTC 2014


Hello,

I'm writing a plugin which includes it's own model. The model is created 
using the SqlAlchemy MetaData object from ckan.model.meta - while this 
isn't available via the toolkit, it seemed to make more sense than 
creating a separate SqlAlchemy engine. I import the model from plugin.py 
to ensure that the model is added to the metadata when the plugin is 
loaded (as this particular plugin implement IConfigurer that happens 
early on).

On an already setup site I was expecting running `paster --plugin=ckan 
db upgrade -c development.ini` would create my table - but that didn't 
work. What did work however is running `paster --plugin=ckan db 
create-from-model -c development.ini`.

Is this how it is expected to work? Or is it better to create a custom 
command in the plugin to create just that table?

Thanks,
Alice



More information about the ckan-dev mailing list