Module migrate.changeset – Schema changes

Module migrate.changeset – Schema migration API

Module ansisql – Standard SQL implementation

Extensions to SQLAlchemy for altering existing tables.

At the moment, this isn’t so much based off of ANSI as much as things that just happen to work with multiple databases.

class migrate.changeset.ansisql.ANSIColumnDropper(dialect, connection, **kw)

Extends ANSI SQL dropper for column dropping (ALTER TABLE DROP COLUMN).

visit_column(column)

Drop a column from its table.

Parameters:

column (sqlalchemy.Column) – the column object

class migrate.changeset.ansisql.ANSIColumnGenerator(dialect, connection, **kw)

Extends ansisql generator for column creation (alter table add col)

visit_column(column)

Create a column (table already exists).

Parameters:

column (sqlalchemy.Column instance) – column object

class migrate.changeset.ansisql.ANSIConstraintCommon(dialect, connection, **kw)

Migrate’s constraints require a separate creation function from SA’s: Migrate’s constraints are created independently of a table; SA’s are created at the same time as the table.

get_constraint_name(cons)

Gets a name for the given constraint.

If the name is already set it will be used otherwise the constraint’s autoname method is used.

Parameters:

cons – constraint object

class migrate.changeset.ansisql.ANSIConstraintDropper(dialect, connection, **kw)
class migrate.changeset.ansisql.ANSIConstraintGenerator(dialect, connection, **kw)
class migrate.changeset.ansisql.ANSIDialect(paramstyle: _ParamStyle | None = None, isolation_level: IsolationLevel | None = None, dbapi: ModuleType | None = None, implicit_returning: Literal[True] = True, supports_native_boolean: bool | None = None, max_identifier_length: int | None = None, label_length: int | None = None, insertmanyvalues_page_size: _NoArg | int = _NoArg.NO_ARG, use_insertmanyvalues: bool | None = None, compiler_linting: Linting = 0, server_side_cursors: bool = False, **kwargs: Any)
columndropper

alias of ANSIColumnDropper

columngenerator

alias of ANSIColumnGenerator

constraintdropper

alias of ANSIConstraintDropper

constraintgenerator

alias of ANSIConstraintGenerator

schemachanger

alias of ANSISchemaChanger

class migrate.changeset.ansisql.ANSISchemaChanger(dialect, connection, **kw)

Manages changes to existing schema elements.

Note that columns are schema elements; ALTER TABLE ADD COLUMN is in SchemaGenerator.

All items may be renamed. Columns can also have many of their properties - type, for example - changed.

Each function is passed a tuple, containing (object, name); where object is a type of object you’d expect for that function (ie. table for visit_table) and name is the object’s new name. NONE means the name is unchanged.

start_alter_column(table, col_name)

Starts ALTER COLUMN

visit_column(delta)

Rename/change a column.

visit_index(index)

Rename an index

visit_table(table)

Rename a table. Other ops aren’t supported.

class migrate.changeset.ansisql.AlterTableVisitor(dialect, connection, **kw)

Common operations for ALTER TABLE statements.

append(s)

Append content to the SchemaIterator’s query buffer.

execute()

Execute the contents of the SchemaIterator’s buffer.

start_alter_table(param)

Returns the start of an ALTER TABLE SQL-Statement.

Use the param object to determine the table name and use it for building the SQL statement.

Parameters:

param (sqlalchemy.Column, sqlalchemy.Index, sqlalchemy.schema.Constraint, sqlalchemy.Table, or string (table name)) – object to determine the table from

Module constraint – Constraint schema migration API

This module defines standalone schema constraint classes.

class migrate.changeset.constraint.CheckConstraint(sqltext, *args, **kwargs)

Bases: ConstraintChangeset, CheckConstraint

Construct CheckConstraint

Migrate’s additional parameters:

Parameters:
  • sqltext (string) – Plain SQL text to check condition

  • columns (list of Columns instances) – If not name is applied, you must supply this kw to autoname constraint

  • table (Table instance) – If columns are passed as strings, this kw is required

classmethod argument_for(dialect_name, argument_name, default)

Add a new kind of dialect-specific keyword argument for this class.

E.g.:

Index.argument_for("mydialect", "length", None)

some_index = Index('a', 'b', mydialect_length=5)

The DialectKWArgs.argument_for() method is a per-argument way adding extra arguments to the DefaultDialect.construct_arguments dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect.

New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments.

Parameters:
  • dialect_name – name of a dialect. The dialect must be locatable, else a NoSuchModuleError is raised. The dialect must also include an existing DefaultDialect.construct_arguments collection, indicating that it participates in the keyword-argument validation and default system, else ArgumentError is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary.

  • argument_name – name of the parameter.

  • default – default value of the parameter.

contains_column(col: Column[Any]) bool

Return True if this constraint contains the given column.

Note that this object also contains an attribute .columns which is a _expression.ColumnCollection of _schema.Column objects.

copy(*, target_table: Table | None = None, **kw: Any) CheckConstraint

Deprecated since version 1.4: The _schema.CheckConstraint.copy() method is deprecated and will be removed in a future release.

create(*a, **kw)

Create the constraint in the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

ddl_if(dialect: str | None = None, callable_: DDLIfCallable | None = None, state: Any | None = None) Self

apply a conditional DDL rule to this schema item.

These rules work in a similar manner to the ExecutableDDLElement.execute_if() callable, with the added feature that the criteria may be checked within the DDL compilation phase for a construct such as CreateTable. HasConditionalDDL.ddl_if() currently applies towards the Index construct as well as all Constraint constructs.

Parameters:
  • dialect – string name of a dialect, or a tuple of string names to indicate multiple dialect types.

  • callable_ – a callable that is constructed using the same form as that described in :paramref:`.ExecutableDDLElement.execute_if.callable_`.

  • state – any arbitrary object that will be passed to the callable, if present.

New in version 2.0.

See also

schema_ddl_ddl_if - background and usage examples

drop(*a, **kw)

Drop the constraint from the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • cascade (bool) – Issue CASCADE drop if database supports it

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

Returns:

Instance with cleared columns

columns: ReadOnlyColumnCollection[str, Column[Any]]

A _expression.ColumnCollection representing the set of columns for this constraint.

dialect_kwargs

A collection of keyword arguments specified as dialect-specific options to this construct.

The arguments are present here in their original <dialect>_<kwarg> format. Only arguments that were actually passed are included; unlike the DialectKWArgs.dialect_options collection, which contains all options known by this dialect including defaults.

The collection is also writable; keys are accepted of the form <dialect>_<kwarg> where the value will be assembled into the list of options.

See also

DialectKWArgs.dialect_options - nested dictionary form

dialect_options

A collection of keyword arguments specified as dialect-specific options to this construct.

This is a two-level nested registry, keyed to <dialect_name> and <argument_name>. For example, the postgresql_where argument would be locatable as:

arg = my_object.dialect_options['postgresql']['where']

New in version 0.9.2.

See also

DialectKWArgs.dialect_kwargs - flat dictionary form

info

Info dictionary associated with the object, allowing user-defined data to be associated with this SchemaItem.

The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as _schema.Table and _schema.Column.

property kwargs

A synonym for DialectKWArgs.dialect_kwargs.

class migrate.changeset.constraint.ConstraintChangeset

Bases: object

Base class for Constraint classes.

create(*a, **kw)

Create the constraint in the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

drop(*a, **kw)

Drop the constraint from the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • cascade (bool) – Issue CASCADE drop if database supports it

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

Returns:

Instance with cleared columns

class migrate.changeset.constraint.ForeignKeyConstraint(columns, refcolumns, *args, **kwargs)

Bases: ConstraintChangeset, ForeignKeyConstraint

Construct ForeignKeyConstraint

Migrate’s additional parameters:

Parameters:
  • columns (list of strings or Column instances) – Columns in constraint

  • refcolumns (list of strings or Column instances) – Columns that this FK reffers to in another table.

  • table (Table instance) – If columns are passed as strings, this kw is required

classmethod argument_for(dialect_name, argument_name, default)

Add a new kind of dialect-specific keyword argument for this class.

E.g.:

Index.argument_for("mydialect", "length", None)

some_index = Index('a', 'b', mydialect_length=5)

The DialectKWArgs.argument_for() method is a per-argument way adding extra arguments to the DefaultDialect.construct_arguments dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect.

New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments.

Parameters:
  • dialect_name – name of a dialect. The dialect must be locatable, else a NoSuchModuleError is raised. The dialect must also include an existing DefaultDialect.construct_arguments collection, indicating that it participates in the keyword-argument validation and default system, else ArgumentError is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary.

  • argument_name – name of the parameter.

  • default – default value of the parameter.

autoname()

Mimic the database’s automatic constraint names

contains_column(col: Column[Any]) bool

Return True if this constraint contains the given column.

Note that this object also contains an attribute .columns which is a _expression.ColumnCollection of _schema.Column objects.

copy(*, schema: str | None = None, target_table: Table | None = None, **kw: Any) ForeignKeyConstraint

Deprecated since version 1.4: The _schema.ForeignKeyConstraint.copy() method is deprecated and will be removed in a future release.

create(*a, **kw)

Create the constraint in the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

ddl_if(dialect: str | None = None, callable_: DDLIfCallable | None = None, state: Any | None = None) Self

apply a conditional DDL rule to this schema item.

These rules work in a similar manner to the ExecutableDDLElement.execute_if() callable, with the added feature that the criteria may be checked within the DDL compilation phase for a construct such as CreateTable. HasConditionalDDL.ddl_if() currently applies towards the Index construct as well as all Constraint constructs.

Parameters:
  • dialect – string name of a dialect, or a tuple of string names to indicate multiple dialect types.

  • callable_ – a callable that is constructed using the same form as that described in :paramref:`.ExecutableDDLElement.execute_if.callable_`.

  • state – any arbitrary object that will be passed to the callable, if present.

New in version 2.0.

See also

schema_ddl_ddl_if - background and usage examples

drop(*a, **kw)

Drop the constraint from the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • cascade (bool) – Issue CASCADE drop if database supports it

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

Returns:

Instance with cleared columns

property column_keys: Sequence[str]

Return a list of string keys representing the local columns in this _schema.ForeignKeyConstraint.

This list is either the original string arguments sent to the constructor of the _schema.ForeignKeyConstraint, or if the constraint has been initialized with _schema.Column objects, is the string .key of each element.

columns: ReadOnlyColumnCollection[str, Column[Any]]

A _expression.ColumnCollection representing the set of columns for this constraint.

dialect_kwargs

A collection of keyword arguments specified as dialect-specific options to this construct.

The arguments are present here in their original <dialect>_<kwarg> format. Only arguments that were actually passed are included; unlike the DialectKWArgs.dialect_options collection, which contains all options known by this dialect including defaults.

The collection is also writable; keys are accepted of the form <dialect>_<kwarg> where the value will be assembled into the list of options.

See also

DialectKWArgs.dialect_options - nested dictionary form

dialect_options

A collection of keyword arguments specified as dialect-specific options to this construct.

This is a two-level nested registry, keyed to <dialect_name> and <argument_name>. For example, the postgresql_where argument would be locatable as:

arg = my_object.dialect_options['postgresql']['where']

New in version 0.9.2.

See also

DialectKWArgs.dialect_kwargs - flat dictionary form

elements: List[ForeignKey]

A sequence of _schema.ForeignKey objects.

Each _schema.ForeignKey represents a single referring column/referred column pair.

This collection is intended to be read-only.

info

Info dictionary associated with the object, allowing user-defined data to be associated with this SchemaItem.

The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as _schema.Table and _schema.Column.

property kwargs

A synonym for DialectKWArgs.dialect_kwargs.

property referred_table: Table

The _schema.Table object to which this _schema.ForeignKeyConstraint references.

This is a dynamically calculated attribute which may not be available if the constraint and/or parent table is not yet associated with a metadata collection that contains the referred table.

class migrate.changeset.constraint.PrimaryKeyConstraint(*cols, **kwargs)

Bases: ConstraintChangeset, PrimaryKeyConstraint

Construct PrimaryKeyConstraint

Migrate’s additional parameters:

Parameters:
  • cols (strings or Column instances) – Columns in constraint.

  • table (Table instance) – If columns are passed as strings, this kw is required

classmethod argument_for(dialect_name, argument_name, default)

Add a new kind of dialect-specific keyword argument for this class.

E.g.:

Index.argument_for("mydialect", "length", None)

some_index = Index('a', 'b', mydialect_length=5)

The DialectKWArgs.argument_for() method is a per-argument way adding extra arguments to the DefaultDialect.construct_arguments dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect.

New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments.

Parameters:
  • dialect_name – name of a dialect. The dialect must be locatable, else a NoSuchModuleError is raised. The dialect must also include an existing DefaultDialect.construct_arguments collection, indicating that it participates in the keyword-argument validation and default system, else ArgumentError is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary.

  • argument_name – name of the parameter.

  • default – default value of the parameter.

autoname()

Mimic the database’s automatic constraint names

contains_column(col: Column[Any]) bool

Return True if this constraint contains the given column.

Note that this object also contains an attribute .columns which is a _expression.ColumnCollection of _schema.Column objects.

copy(*, target_table: Table | None = None, **kw: Any) ColumnCollectionConstraint

Deprecated since version 1.4: The _schema.ColumnCollectionConstraint.copy() method is deprecated and will be removed in a future release.

create(*a, **kw)

Create the constraint in the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

ddl_if(dialect: str | None = None, callable_: DDLIfCallable | None = None, state: Any | None = None) Self

apply a conditional DDL rule to this schema item.

These rules work in a similar manner to the ExecutableDDLElement.execute_if() callable, with the added feature that the criteria may be checked within the DDL compilation phase for a construct such as CreateTable. HasConditionalDDL.ddl_if() currently applies towards the Index construct as well as all Constraint constructs.

Parameters:
  • dialect – string name of a dialect, or a tuple of string names to indicate multiple dialect types.

  • callable_ – a callable that is constructed using the same form as that described in :paramref:`.ExecutableDDLElement.execute_if.callable_`.

  • state – any arbitrary object that will be passed to the callable, if present.

New in version 2.0.

See also

schema_ddl_ddl_if - background and usage examples

drop(*a, **kw)

Drop the constraint from the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • cascade (bool) – Issue CASCADE drop if database supports it

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

Returns:

Instance with cleared columns

columns: ReadOnlyColumnCollection[str, Column[Any]]

A _expression.ColumnCollection representing the set of columns for this constraint.

dialect_kwargs

A collection of keyword arguments specified as dialect-specific options to this construct.

The arguments are present here in their original <dialect>_<kwarg> format. Only arguments that were actually passed are included; unlike the DialectKWArgs.dialect_options collection, which contains all options known by this dialect including defaults.

The collection is also writable; keys are accepted of the form <dialect>_<kwarg> where the value will be assembled into the list of options.

See also

DialectKWArgs.dialect_options - nested dictionary form

dialect_options

A collection of keyword arguments specified as dialect-specific options to this construct.

This is a two-level nested registry, keyed to <dialect_name> and <argument_name>. For example, the postgresql_where argument would be locatable as:

arg = my_object.dialect_options['postgresql']['where']

New in version 0.9.2.

See also

DialectKWArgs.dialect_kwargs - flat dictionary form

info

Info dictionary associated with the object, allowing user-defined data to be associated with this SchemaItem.

The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as _schema.Table and _schema.Column.

property kwargs

A synonym for DialectKWArgs.dialect_kwargs.

class migrate.changeset.constraint.UniqueConstraint(*cols, **kwargs)

Bases: ConstraintChangeset, UniqueConstraint

Construct UniqueConstraint

Migrate’s additional parameters:

Parameters:
  • cols (strings or Column instances) – Columns in constraint.

  • table (Table instance) – If columns are passed as strings, this kw is required

New in version 0.6.0.

classmethod argument_for(dialect_name, argument_name, default)

Add a new kind of dialect-specific keyword argument for this class.

E.g.:

Index.argument_for("mydialect", "length", None)

some_index = Index('a', 'b', mydialect_length=5)

The DialectKWArgs.argument_for() method is a per-argument way adding extra arguments to the DefaultDialect.construct_arguments dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect.

New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments.

Parameters:
  • dialect_name – name of a dialect. The dialect must be locatable, else a NoSuchModuleError is raised. The dialect must also include an existing DefaultDialect.construct_arguments collection, indicating that it participates in the keyword-argument validation and default system, else ArgumentError is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary.

  • argument_name – name of the parameter.

  • default – default value of the parameter.

autoname()

Mimic the database’s automatic constraint names

contains_column(col: Column[Any]) bool

Return True if this constraint contains the given column.

Note that this object also contains an attribute .columns which is a _expression.ColumnCollection of _schema.Column objects.

copy(*, target_table: Table | None = None, **kw: Any) ColumnCollectionConstraint

Deprecated since version 1.4: The _schema.ColumnCollectionConstraint.copy() method is deprecated and will be removed in a future release.

create(*a, **kw)

Create the constraint in the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

ddl_if(dialect: str | None = None, callable_: DDLIfCallable | None = None, state: Any | None = None) Self

apply a conditional DDL rule to this schema item.

These rules work in a similar manner to the ExecutableDDLElement.execute_if() callable, with the added feature that the criteria may be checked within the DDL compilation phase for a construct such as CreateTable. HasConditionalDDL.ddl_if() currently applies towards the Index construct as well as all Constraint constructs.

Parameters:
  • dialect – string name of a dialect, or a tuple of string names to indicate multiple dialect types.

  • callable_ – a callable that is constructed using the same form as that described in :paramref:`.ExecutableDDLElement.execute_if.callable_`.

  • state – any arbitrary object that will be passed to the callable, if present.

New in version 2.0.

See also

schema_ddl_ddl_if - background and usage examples

drop(*a, **kw)

Drop the constraint from the database.

Parameters:
  • engine (sqlalchemy.engine.base.Engine) – the database engine to use. If this is None the instance’s engine will be used

  • cascade (bool) – Issue CASCADE drop if database supports it

  • connection (sqlalchemy.engine.base.Connection instance) – reuse connection istead of creating new one.

Returns:

Instance with cleared columns

columns: ReadOnlyColumnCollection[str, Column[Any]]

A _expression.ColumnCollection representing the set of columns for this constraint.

dialect_kwargs

A collection of keyword arguments specified as dialect-specific options to this construct.

The arguments are present here in their original <dialect>_<kwarg> format. Only arguments that were actually passed are included; unlike the DialectKWArgs.dialect_options collection, which contains all options known by this dialect including defaults.

The collection is also writable; keys are accepted of the form <dialect>_<kwarg> where the value will be assembled into the list of options.

See also

DialectKWArgs.dialect_options - nested dictionary form

dialect_options

A collection of keyword arguments specified as dialect-specific options to this construct.

This is a two-level nested registry, keyed to <dialect_name> and <argument_name>. For example, the postgresql_where argument would be locatable as:

arg = my_object.dialect_options['postgresql']['where']

New in version 0.9.2.

See also

DialectKWArgs.dialect_kwargs - flat dictionary form

info

Info dictionary associated with the object, allowing user-defined data to be associated with this SchemaItem.

The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as _schema.Table and _schema.Column.

property kwargs

A synonym for DialectKWArgs.dialect_kwargs.

Module databases – Database specific schema migration

This module contains database dialect specific changeset implementations.

Module mysql

Module firebird

Module oracle

Module postgres

Module sqlite

Module visitor

Module schema – Additional API to SQLAlchemy for migrations

Module migrate.versioning – Database versioning and repository management

This package provides functionality to create and manage repositories of database schema changesets and to apply these changesets to databases.

Module api – Python API commands

Module genmodel – ORM Model generator

Module pathed – Path utilities

Module repository – Repository management

Module schema – Migration upgrade/downgrade

Module schemadiff – ORM Model differencing

Schema differencing support.

class migrate.versioning.schemadiff.ColDiff(col_A, col_B)

Container for differences in one Column between two Table instances, A and B.

col_A

The Column object for A.

col_B

The Column object for B.

type_A

The most generic type of the Column object in A.

type_B

The most generic type of the Column object in A.

class migrate.versioning.schemadiff.SchemaDiff(metadataA, metadataB, labelA='metadataA', labelB='metadataB', excludeTables=None)

Compute the difference between two MetaData objects.

The string representation of a SchemaDiff will summarise the changes found between the two MetaData objects.

The length of a SchemaDiff will give the number of changes found, enabling it to be used much like a boolean in expressions.

Parameters:
  • metadataA – First MetaData to compare.

  • metadataB – Second MetaData to compare.

  • labelA – The label to use in messages about the first MetaData.

  • labelB – The label to use in messages about the second MetaData.

  • excludeTables – A sequence of table names to exclude.

tables_missing_from_A

A sequence of table names that were found in B but weren’t in A.

tables_missing_from_B

A sequence of table names that were found in A but weren’t in B.

tables_different

A dictionary containing information about tables that were found to be different. It maps table names to a TableDiff objects describing the differences found.

class migrate.versioning.schemadiff.TableDiff

Container for differences in one Table between two MetaData instances, A and B.

columns_missing_from_A

A sequence of column names that were found in B but weren’t in A.

columns_missing_from_B

A sequence of column names that were found in A but weren’t in B.

columns_different

A dictionary containing information about columns that were found to be different. It maps column names to a ColDiff objects describing the differences found.

migrate.versioning.schemadiff.getDiffOfModelAgainstDatabase(metadata, engine, excludeTables=None)

Return differences of model against database.

Returns:

object which will evaluate to True if there are differences else False.

migrate.versioning.schemadiff.getDiffOfModelAgainstModel(metadataA, metadataB, excludeTables=None)

Return differences of model against another model.

Returns:

object which will evaluate to True if there are differences else False.

Module script – Script actions

Module shell – CLI interface

Module util – Various utility functions

Module version – Versioning management

Module exceptions – Exception definitions

Provide exception classes for migrate

exception migrate.exceptions.ApiError

Base class for API errors.

exception migrate.exceptions.ControlledSchemaError

Base class for controlled schema errors.

exception migrate.exceptions.DatabaseAlreadyControlledError

Database shouldn’t be under version control, but it is

exception migrate.exceptions.DatabaseNotControlledError

Database should be under version control, but it’s not.

exception migrate.exceptions.Error

Error base class.

exception migrate.exceptions.InvalidConstraintError

Invalid constraint error

exception migrate.exceptions.InvalidRepositoryError

Invalid repository error.

exception migrate.exceptions.InvalidScriptError

Invalid script error.

exception migrate.exceptions.InvalidVersionError

Invalid version error.

exception migrate.exceptions.KnownError

A known error condition.

exception migrate.exceptions.MigrateDeprecationWarning

Warning for deprecated features in Migrate

exception migrate.exceptions.NoSuchTableError

The table does not exist.

exception migrate.exceptions.NotSupportedError

Not supported error

exception migrate.exceptions.PathError

Base class for path errors.

exception migrate.exceptions.PathFoundError

A path with a file was required; found no file.

exception migrate.exceptions.PathNotFoundError

A path with no file was required; found a file.

exception migrate.exceptions.RepositoryError

Base class for repository errors.

exception migrate.exceptions.ScriptError

Base class for script errors.

exception migrate.exceptions.UsageError

A known error condition where help should be displayed.

exception migrate.exceptions.VersionNotFoundError

Specified version is not present.

exception migrate.exceptions.WrongRepositoryError

This database is under version control by another repository.