I am interested in supporting multiple packages that depend on each other's tables as a directed acyclic graph and do not import a common declarative base. To support that goal I've been working on stucco_evolution. stucco_evolution is an extension of repoze.evolution that works with SQLAlchemy.
This is the design. Let me know if this would be useful to you. Packages that support stucco_evolution must contain a package named evolve. evolve/__init__.py contains some metadata, evolve/create.py creates all the tables for the latest version of the schema, and evolve/evolveN.py does the work necessary to upgrade the schema to version N from version N-1. Given a package name, stucco_evolution will try to import the evolve package inside that package and the evolve package from all its dependencies. stucco_evolution will return a topologically sorted list of these modules and evolution managers for each of these modules. By calling create() on each manager from the list in order, tables should be created in database-acceptable order. By calling repoze_evolution.evolve_to_latest(manager) with each manager from the list, all the schemas are brought up to the latest version. If this fails you will probably have a bad day. To upgrade your package to work with stucco_evolution, you would just add a packagename/evolve directory, add a couple of scripts (not evolve1.py until you have your first upgrade), and call session.begin() create_many(build_managers(session, find_dependencies('packagename'))) # create all tables for packagename and dependencies session.commit() The implementation is at https://bitbucket.org/dholth/stucco_evolution stucco_evolution purposefully does not know anything about SQL, but there's nothing to stop you from using a DDL abstraction library in an evolveN script. __init__.py: NAME = 'a name' VERSION = 1 # an integer. start at 0 with no evolveN scripts. DEPENDS = ['stucco_evolution'] # a list containing 'stucco_evolution' except in stucco_evolution itself. create.py: def create(session): import mypackage mypackage.Base.metadata.create_all(session.bind) evolve1.py: def evolve(session): session.execute("ALTER TABLE foo ADD COLUMN baz INTEGER") -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.