jstacoder / flask-cms

a minimal CMS built on the pythonic MTV (model / template / view) pattern, implemented using the flask webframework
136 stars 37 forks source link

sqlalchemy.exc.InvalidRequestError: Table 'directories' is already defined for this MetaData instance. #14

Closed cstrutton closed 9 years ago

cstrutton commented 9 years ago

I get the following traceback when running `python manage.py db upgrade:

(venv)chris@chris-NE56R:~/devops/rodandfly/flask-cms/flask_cms$ python manage.py db upgrade
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    from app import app
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/app.py", line 12, in <module>
    app = AppFactory(DevelopmentConfig).get_app(__name__)
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/main/factory.py", line 41, in get_app
    self._register_routes()
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/main/factory.py", line 106, in _register_routes
    module,r_name = self._get_imported_stuff_by_path(url_module)
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/main/factory.py", line 49, in _get_imported_stuff_by_path
    module = import_string(module_name)
  File "/home/chris/devops/rodandfly/flask-cms/venv/local/lib/python2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/utils.py", line 414, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/fileviewer/__init__.py", line 8, in <module>
    from models import *
  File "/home/chris/devops/rodandfly/flask-cms/flask_cms/fileviewer/models.py", line 14, in <module>
    class Directory(BaseMixin):
  File "/home/chris/devops/rodandfly/flask-cms/venv/local/lib/python2.7/site-    packages/Flask_SQLAlchemy-2.0-py2.7.egg/flask_sqlalchemy/__init__.py", line 536, in __init__
    DeclarativeMeta.__init__(self, name, bases, d)
  File "/home/chris/devops/rodandfly/flask-cms/venv/local/lib/python2.7/site-packages/SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg/sqlalchemy/ext/declarative/api.py", line 55, in __init__
    _as_declarative(cls, classname, cls.__dict__)
  File "/home/chris/devops/rodandfly/flask-cms/venv/local/lib/python2.7/site-packages/SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg/sqlalchemy/ext/declarative/base.py", line 254, in _as_declarative
    **table_kw)
  File "/home/chris/devops/rodandfly/flask-cms/venv/local/lib/python2.7/site-packages/SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg/sqlalchemy/sql/schema.py", line 393, in __new__
    "existing Table object." % key)
sqlalchemy.exc.InvalidRequestError: Table 'directories' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.

Note: this is after my requirements.txt modifications from my previous issues.

Thanks in advance for your help Chris

jstacoder commented 9 years ago

so this was caused by a few things, namely me using a single file to try and import all of the models in the manage.py file, so i removed that import file, and its reference in the manage.py file, and i updated the requirements.txt file to get the install working, and i forgot to mention, to get it working you should install flask_cms inside of your virtualenv,

. ./VIRTUALENV/bin/activate
python setup.py develop

that should install all of the dependency's from pypi and then

python manage.py db upgrade

should work

jstacoder commented 9 years ago

ok fe7230a should fix this for good, i was able to successfully run

python managey.py db upgrade

in a clean virtualenv. just make sure you have my latest commits applied

jstacoder commented 9 years ago

ok some more fixs, but now i got it fully up and running in a clean env, you should be good now

cstrutton commented 9 years ago

Thanks for all the effort and the quick responses.