qizhiyi / sqlalchemy-migrate

Automatically exported from code.google.com/p/sqlalchemy-migrate
MIT License
0 stars 0 forks source link

Support for (postgresql) schemas #89

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Migrate currently supports only 'public' schema. 

More on postgresql schemas: 
http://www.postgresql.org/docs/8.1/interactive/ddl-schemas.html

Debate on ML: 
http://groups.google.com/group/migrate-users/browse_thread/thread/56020130b053ad
1

Original issue reported on code.google.com by iElect...@gmail.com on 6 Aug 2010 at 2:01

GoogleCodeExporter commented 8 years ago
I would like to say schema is very useful not only for postgresql but for 
oracle and db2.

The key thing need to change is migrate/version/schema.py. 

https://github.com/stackforge/sqlalchemy-migrate/blob/master/migrate/versioning/
schema.py

In method _create_table_version, we need to add a schema param to support table 
with schema

table = Table(
            tname, meta,
            Column('repository_id', String(250), primary_key=True),
            Column('repository_path', Text),
            Column('version', Integer), 
            schema=schema_name
)

in method load, we need to add a schema param to enable the table to be 
correctly auto-reflected.

if not hasattr(self, 'table') or self.table is None:
                    self.table = Table(tname, self.meta, autoload=True, schema=schema_name)

Original comment by godsarm...@gmail.com on 17 Jul 2014 at 6:14