0

I would like to add a new column in my existing database, initially created by sqlalchemy.

I tried using the sqlalchemy-migrate tool to do this and running into the following error:

C:\Users\sk11\Desktop\playground\migrateDB>%PYTHON_EXE% manage.py db_version
Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    main(url='sqlite:///Results.db', debug='False', repository='sdb')
  File "C:\Python27\lib\site-packages\sqlalchemy_migrate-0.7.2-py2.7.egg\migrate\versioning\shell.py", line 207, in main
    ret = command_func(**kwargs)
  File "<string>", line 2, in db_version
  File "C:\Python27\lib\site-packages\sqlalchemy_migrate-0.7.2-py2.7.egg\migrate\versioning\util\__init__.py", line 159, in with_engine
    return f(*a, **kw)
  File "C:\Python27\lib\site-packages\sqlalchemy_migrate-0.7.2-py2.7.egg\migrate\versioning\api.py", line 148, in db_version
    schema = ControlledSchema(engine, repository)
  File "C:\Python27\lib\site-packages\sqlalchemy_migrate-0.7.2-py2.7.egg\migrate\versioning\schema.py", line 32, in __init__
    self.load()
  File "C:\Python27\lib\site-packages\sqlalchemy_migrate-0.7.2-py2.7.egg\migrate\versioning\schema.py", line 44, in load
    self.table = Table(tname, self.meta, autoload=True)
  File "build\bdist.win32\egg\sqlalchemy\schema.py", line 318, in __new__
  File "build\bdist.win32\egg\sqlalchemy\schema.py", line 381, in _init
  File "build\bdist.win32\egg\sqlalchemy\schema.py", line 408, in _autoload
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 2426, in run_callable
  File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 1969, in run_callable
  File "build\bdist.win32\egg\sqlalchemy\engine\default.py", line 260, in reflecttable
  File "build\bdist.win32\egg\sqlalchemy\engine\reflection.py", line 412, in reflecttable
migrate.exceptions.DatabaseNotControlledError: migrate_version

I followed exactly the same steps as explained in the docs. Before checking for db_version (for which I am getting the above error) I tried version command which worked fine.

C:\Users\sk11\Desktop\playground\migrateDB>C:\Python27\Scripts\migrate.exe manage manage.py --repository=sdb --url=sqlite:///Results.db

C:\Users\sk11\Desktop\playground\migrateDB>%PYTHON_EXE% manage.py version
0

Any ideas where to look further or what I am doing wrong?

sk11
  • 1,779
  • 1
  • 17
  • 29

1 Answers1

3

I realized that the database was not added to the repository version control.

Since I have multiple databases under my repository, I was adding the wrong database instead of the one I wanted to.

$ python my_repository/manage.py version_control sqlite:///project.db my_repository
sk11
  • 1,779
  • 1
  • 17
  • 29