diff --git a/rhodecode/lib/dbmigrate/migrate/changeset/schema.py b/rhodecode/lib/dbmigrate/migrate/changeset/schema.py --- a/rhodecode/lib/dbmigrate/migrate/changeset/schema.py +++ b/rhodecode/lib/dbmigrate/migrate/changeset/schema.py @@ -31,7 +31,7 @@ __all__ = [ def create_column(column, table=None, *p, **kw): """Create a column, given the table. - + API to :meth:`ChangesetColumn.create`. """ if table is not None: @@ -41,7 +41,7 @@ def create_column(column, table=None, *p def drop_column(column, table=None, *p, **kw): """Drop a column, given the table. - + API to :meth:`ChangesetColumn.drop`. """ if table is not None: @@ -105,12 +105,12 @@ def alter_column(*p, **k): :param engine: The :class:`~sqlalchemy.engine.base.Engine` to use for table reflection and schema alterations. - + :returns: A :class:`ColumnDelta` instance representing the change. - + """ - + if 'table' not in k and isinstance(p[0], sqlalchemy.Column): k['table'] = p[0].table if 'engine' not in k: @@ -129,7 +129,7 @@ def alter_column(*p, **k): # that this crutch has to be left in until they can be sorted # out k['alter_metadata']=True - + delta = ColumnDelta(*p, **k) visitorcallable = get_engine_visitor(engine, 'schemachanger') @@ -183,10 +183,10 @@ class ColumnDelta(DictMixin, sqlalchemy. :param table: Table at which current Column should be bound to.\ If table name is given, reflection will be used. :type table: string or Table instance - + :param metadata: A :class:`MetaData` instance to store reflected table names - + :param engine: When reflecting tables, either engine or metadata must \ be specified to acquire engine object. :type engine: :class:`Engine` instance @@ -211,7 +211,7 @@ class ColumnDelta(DictMixin, sqlalchemy. # as a crutch until the tests that fail when 'alter_metadata' # behaviour always happens can be sorted out self.alter_metadata = kw.pop("alter_metadata", False) - + self.meta = kw.pop("metadata", None) self.engine = kw.pop("engine", None) @@ -239,7 +239,7 @@ class ColumnDelta(DictMixin, sqlalchemy. self.alter_metadata, super(ColumnDelta, self).__repr__() ) - + def __getitem__(self, key): if key not in self.keys(): raise KeyError("No such diff key, available: %s" % self.diffs ) @@ -278,7 +278,7 @@ class ColumnDelta(DictMixin, sqlalchemy. """Compares two Column objects""" self.process_column(new_col) self.table = k.pop('table', None) - # we cannot use bool() on table in SA06 + # we cannot use bool() on table in SA06 if self.table is None: self.table = old_col.table if self.table is None: @@ -367,7 +367,7 @@ class ColumnDelta(DictMixin, sqlalchemy. for_update=True)) if toinit: column._init_items(*toinit) - + if not SQLA_06: column.args = [] @@ -484,7 +484,7 @@ class ChangesetColumn(object): def alter(self, *p, **k): """Makes a call to :func:`alter_column` for the column this - method is called on. + method is called on. """ if 'table' not in k: k['table'] = self.table @@ -559,12 +559,12 @@ populated with defaults def _col_name_in_constraint(self,cons,name): return False - + def remove_from_table(self, table, unset_table=True): # TODO: remove primary keys, constraints, etc if unset_table: self.table = None - + to_drop = set() for index in table.indexes: columns = [] @@ -576,7 +576,7 @@ populated with defaults else: to_drop.add(index) table.indexes = table.indexes - to_drop - + to_drop = set() for cons in table.constraints: # TODO: deal with other types of constraint @@ -588,7 +588,7 @@ populated with defaults if self.name==col_name: to_drop.add(cons) table.constraints = table.constraints - to_drop - + if table.c.contains_column(self): table.c.remove(self)