Ticket #83 (closed defect: invalid)

Opened 3 years ago

Last modified 2 years ago

Problems with migrate

Reported by: guest Owned by:
Priority: normal Milestone:
Component: core Version:
Keywords: Cc:

Description

  • migrate creates empty tables when upgrading models with shortnames=False, you have to specify the tables prefix using tablenames, or set shortnames}} to {{{True. Also, as migrate creates upgrade scripts named with the database version (1.py, 2.py, etc...), you end up with table names prefixed with the version number.
  • the inverse keyword must be specified for every OneToMany relationship or you get errors like this :
    $ ./manage.py upgrade
    0 -> 1... 
    Traceback (most recent call last):
      File "./manage.py", line 5, in <module>
        main(url='sqlite:///test.sqlite', repository='repository')
      File "/usr/lib/python2.5/site-packages/migrate/versioning/shell.py", line 133, in main
        ret = command(**kwargs)
      File "/usr/lib/python2.5/site-packages/migrate/versioning/api.py", line 199, in upgrade
        return _migrate(url,repository,version,upgrade=True,err=err,**opts)
      File "/usr/lib/python2.5/site-packages/migrate/versioning/api.py", line 235, in _migrate
        schema.runchange(ver,change,changeset.step)
      File "/usr/lib/python2.5/site-packages/migrate/versioning/schema.py", line 120, in runchange
        change.run(self.engine,step)
      File "/usr/lib/python2.5/site-packages/migrate/versioning/script/py.py", line 62, in run
        func()
      File "db_repository/versions/1/1.py", line 98, in upgrade
        create_all()
      File "/usr/lib/python2.5/site-packages/elixir/__init__.py", line 99, in create_all
        md.create_all(*args, **kwargs)
      File "/var/lib/python-support/python2.5/sqlalchemy/schema.py", line 1582, in create_all
        bind.create(self, checkfirst=checkfirst, tables=tables)
      File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1139, in create
        self._run_visitor(self.dialect.schemagenerator, entity, connection=connection, **kwargs)
      File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1168, in _run_visitor
        visitorcallable(self.dialect, conn, **kwargs).traverse(element)
      File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 75, in traverse
        return self._non_cloned_traversal(obj)
      File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 134, in _non_cloned_traversal
        self.traverse_single(target)
      File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 35, in traverse_single
        return meth(obj, **kwargs)
      File "/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py", line 756, in visit_metadata
        collection = [t for t in metadata.table_iterator(reverse=False, tables=self.tables) if (not self.checkfirst or not self.dialect.has_table(self.connection, t.name, schema=t.schema))]
      File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 691, in table_iterator
        elixir.setup_all()
      File "/usr/lib/python2.5/site-packages/elixir/__init__.py", line 117, in setup_all
        setup_entities(entities)
      File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 751, in setup_entities
        method()
      File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 191, in create_pk_cols
        self.call_builders('create_pk_cols')
      File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 435, in call_builders
        getattr(builder, what)()
      File "/usr/lib/python2.5/site-packages/elixir/relationships.py", line 372, in create_pk_cols
        self.create_keys(True)
      File "/usr/lib/python2.5/site-packages/elixir/relationships.py", line 632, in create_keys
        self.entity.__name__))
    Exception: Couldn't find any relationship in 'User' which match as 
    inverse of the 'users' relationship defined in the 'Group' entity. 
    If you are using inheritance you might need to specify inverse 
    relationships manually by using the inverse keyword.
    

(tested with ubuntu versions of elixir 0.5.2 and migrate 0.4.4)

Change History

Changed 2 years ago by ged

  • status changed from new to closed
  • resolution set to invalid

Somehow this bug report escaped my radar all this time. Sorry about that.

I can't do anything about the first issue. This is unfortunate but expected. You could provide a custom Entity-to-tablename function which would produce the correct names in that case.

As for the second issue, I would need a (minimal) test case to be able to do anything.

Closing the bug for now. Please reopen it if you can provide a test case.

Note: See TracTickets for help on using tickets.