Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with alembic and initializedb when the script is lauch from a child application #67

Open
miniwark opened this issue Nov 20, 2012 · 0 comments
Assignees
Labels
Milestone

Comments

@miniwark
Copy link
Member

If the initialize_db script is used by an extended application, he did not correctly check the alembic version of the database.

(env)miniwark@lazaret:/home/miniwark/anuket/begotemp# initialize_anuket_db development.ini 
2012-11-12 17:29:14,199 INFO  [sqlalchemy.engine.base.Engine][MainThread] select version()
2012-11-12 17:29:14,199 INFO  [sqlalchemy.engine.base.Engine][MainThread] {}
2012-11-12 17:29:14,201 INFO  [sqlalchemy.engine.base.Engine][MainThread] select current_schema()
2012-11-12 17:29:14,201 INFO  [sqlalchemy.engine.base.Engine][MainThread] {}
2012-11-12 17:29:14,205 INFO  [sqlalchemy.engine.base.Engine][MainThread] BEGIN (implicit)
2012-11-12 17:29:14,206 INFO  [sqlalchemy.engine.base.Engine][MainThread] select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=current_schema() and relname=%(name)s
2012-11-12 17:29:14,206 INFO  [sqlalchemy.engine.base.Engine][MainThread] {'name': u'alembic_version'}
2012-11-12 17:29:14,209 INFO  [sqlalchemy.engine.base.Engine][MainThread] 
CREATE TABLE alembic_version (
        version_num VARCHAR(32) NOT NULL
)

2012-11-12 17:29:14,209 INFO  [sqlalchemy.engine.base.Engine][MainThread] {}
2012-11-12 17:29:14,211 INFO  [sqlalchemy.engine.base.Engine][MainThread] SELECT alembic_version.version_num 
FROM alembic_version
2012-11-12 17:29:14,212 INFO  [sqlalchemy.engine.base.Engine][MainThread] {}
2012-11-12 17:29:14,213 INFO  [sqlalchemy.engine.base.Engine][MainThread] select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=current_schema() and relname=%(name)s
2012-11-12 17:29:14,213 INFO  [sqlalchemy.engine.base.Engine][MainThread] {'name': u'alembic_version'}
2012-11-12 17:29:14,215 INFO  [sqlalchemy.engine.base.Engine][MainThread] SELECT alembic_version.version_num 
FROM alembic_version
2012-11-12 17:29:14,215 INFO  [sqlalchemy.engine.base.Engine][MainThread] {}
2012-11-12 17:29:14,216 INFO  [sqlalchemy.engine.base.Engine][MainThread] ROLLBACK
Traceback (most recent call last):
  File "/home/miniwark/anuket/env/bin/initialize_anuket_db", line 9, in 
    load_entry_point('anuket==0.6a', 'console_scripts', 'initialize_anuket_db')()
  File "/home/miniwark/anuket/anuket/anuket/scripts/initializedb.py", line 23, in main
    return command.run()
  File "/home/miniwark/anuket/anuket/anuket/scripts/initializedb.py", line 56, in run
    return self.initialize_db()
  File "/home/miniwark/anuket/anuket/anuket/scripts/initializedb.py", line 100, in initialize_db
    stamp(alembic_cfg, 'head')
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/command.py", line 212, in stamp
    script.run_env()
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 191, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/util.py", line 185, in load_python_file
    module = imp.load_source(module_id, path, open(path, 'rb'))
  File "/home/miniwark/anuket/begotemp/begotemp/scripts/alembic/env.py", line 70, in 
    run_migrations_online()
  File "/home/miniwark/anuket/begotemp/begotemp/scripts/alembic/env.py", line 63, in run_migrations_online
    context.run_migrations()
  File "", line 7, in run_migrations
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/environment.py", line 494, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/migration.py", line 200, in run_migrations
    self):
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/command.py", line 199, in do_stamp
    dest = script.get_revision(revision)
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 90, in get_revision
    id_ = self.as_revision_number(id_)
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 116, in as_revision_number
    id_ = self.get_current_head()
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 245, in get_current_head
    current_heads = self.get_heads()
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 269, in get_heads
    for script in self._revision_map.values():
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/util.py", line 219, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/miniwark/anuket/env/local/lib/python2.7/site-packages/alembic/script.py", line 200, in _revision_map
    for file_ in os.listdir(self.versions):
OSError: [Errno 2] No such file or directory: '/home/miniwark/anuket/begotemp/begotemp/scripts/alembic/versions'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant