From c670d1d36a742ffe6c018920359424b7ece2b516 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Thu, 13 Jun 2013 17:17:34 +0200 Subject: added bugfixes for 0.8 --- README | 43 -------------------------------------- README.rst | 49 ++++++++++++++++++++++++++++++++++++++++++++ migrate/changeset/ansisql.py | 14 +++++++++++++ setup.cfg | 2 +- test_db.cfg | 6 ++++-- test_db.cfg.tmpl | 14 ------------- 6 files changed, 68 insertions(+), 60 deletions(-) delete mode 100644 README create mode 100644 README.rst delete mode 100644 test_db.cfg.tmpl diff --git a/README b/README deleted file mode 100644 index 19e7c13..0000000 --- a/README +++ /dev/null @@ -1,43 +0,0 @@ -Inspired by Ruby on Rails' migrations, Migrate provides a way to deal with -database schema changes in `SQLAlchemy `_ projects. - -Migrate extends SQLAlchemy to have database changeset handling. It provides a -database change repository mechanism which can be used from the command line as -well as from inside python code. - -Help ------- - -Sphinx documentation is available at the project page `packages.python.org -`_. - -Users and developers can be found at #sqlalchemy-migrate on Freenode IRC -network and at the public users mailing list `migrate-users -`_. - -New releases and major changes are announced at the public announce mailing -list `migrate-announce `_ -and at the Python package index `sqlalchemy-migrate -`_. - -Homepage is located at `stackforge -`_ - -You can also clone a current `development version -`_ - -Tests and Bugs ------------------- - -To run automated tests: - -* Copy test_db.cfg.tmpl to test_db.cfg -* Edit test_db.cfg with database connection strings suitable for running tests. - (Use empty databases.) -* $ pip install -r requirements.txt -r test-requirements.txt -* $ python setup.py develop -* $ testr run --parallel - -Please report any issues with sqlalchemy-migrate to the issue tracker at -`code.google.com issues -`_ diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..daecfca --- /dev/null +++ b/README.rst @@ -0,0 +1,49 @@ +sqlalchemy-migrate +================== + +Fork from http://code.google.com/p/sqlalchemy-migrate/ to get it working with +SQLAlchemy 0.8. + +Inspired by Ruby on Rails' migrations, Migrate provides a way to deal with +database schema changes in `SQLAlchemy `_ projects. + +Migrate extends SQLAlchemy to have database changeset handling. It provides a +database change repository mechanism which can be used from the command line as +well as from inside python code. + +Help +---- + +Sphinx documentation is available at the project page `packages.python.org +`_. + +Users and developers can be found at #sqlalchemy-migrate on Freenode IRC +network and at the public users mailing list `migrate-users +`_. + +New releases and major changes are announced at the public announce mailing +list `migrate-announce `_ +and at the Python package index `sqlalchemy-migrate +`_. + +Homepage is located at `stackforge +`_ + +You can also clone a current `development version +`_ + +Tests and Bugs +-------------- + +To run automated tests: + +* Copy test_db.cfg.tmpl to test_db.cfg +* Edit test_db.cfg with database connection strings suitable for running tests. + (Use empty databases.) +* $ pip install -r requirements.txt -r test-requirements.txt +* $ python setup.py develop +* $ testr run --parallel + +Please report any issues with sqlalchemy-migrate to the issue tracker at +`code.google.com issues +`_ diff --git a/migrate/changeset/ansisql.py b/migrate/changeset/ansisql.py index 9ded560..79e406c 100644 --- a/migrate/changeset/ansisql.py +++ b/migrate/changeset/ansisql.py @@ -17,6 +17,7 @@ from sqlalchemy.schema import (ForeignKeyConstraint, Index) from migrate import exceptions +import sqlalchemy.sql.compiler from migrate.changeset import constraint from sqlalchemy.schema import AddConstraint, DropConstraint @@ -153,6 +154,19 @@ class ANSISchemaChanger(AlterTableVisitor, SchemaGenerator): name. NONE means the name is unchanged. """ + def _index_identifier(self, ident): + """This function is move in 0.8 to _prepared_index_name""" + if isinstance(ident, sqlalchemy.sql.compiler.sql._truncated_label): + max = self.dialect.max_index_name_length or \ + self.dialect.max_identifier_length + if len(ident) > max: + ident = ident[0:max - 8] + \ + "_" + sqlalchemy.sql.compiler.util.md5_hex(ident)[-4:] + else: + self.dialect.validate_identifier(ident) + + return ident + def visit_table(self, table): """Rename a table. Other ops aren't supported.""" self.start_alter_table(table) diff --git a/setup.cfg b/setup.cfg index f4ddf34..6d78e8c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ name = sqlalchemy-migrate summary = Database schema migration for SQLAlchemy description-file = - README + README.rst author = OpenStack author-email = openstack-dev@lists.openstack.org home-page = http://www.openstack.org/ diff --git a/test_db.cfg b/test_db.cfg index 6dcff72..f628826 100644 --- a/test_db.cfg +++ b/test_db.cfg @@ -8,5 +8,7 @@ # The string '__tmp__' is substituted for a temporary file in each connection # string. This is useful for sqlite tests. sqlite:///__tmp__ -#postgresql://scott:tiger@localhost/test_migrate -#mysql://scott:tiger@localhost/test_migrate +#postgresql://postgres@localhost/testdb +#mysql://root@localhost/testdb +#oracle://scott:tiger@localhost +#firebird://scott:tiger@localhost//var/lib/firebird/databases/test_migrate diff --git a/test_db.cfg.tmpl b/test_db.cfg.tmpl deleted file mode 100644 index 59ea742..0000000 --- a/test_db.cfg.tmpl +++ /dev/null @@ -1,14 +0,0 @@ -# test_db.cfg -# -# This file contains a list of connection strings which will be used by -# database tests. Tests will be executed once for each string in this file. -# You should be sure that the database used for the test doesn't contain any -# important data. See README for more information. -# -# The string '__tmp__' is substituted for a temporary file in each connection -# string. This is useful for sqlite tests. -sqlite:///__tmp__ -postgresql://scott:tiger@localhost/test_migrate -mysql://scott:tiger@localhost/test_migrate -oracle://scott:tiger@localhost -firebird://scott:tiger@localhost//var/lib/firebird/databases/test_migrate -- cgit v1.2.1