diff --git a/README b/README.rst similarity index 91% rename from README rename to README.rst index 19e7c13..daecfca 100644 --- a/README +++ b/README.rst @@ -1,3 +1,9 @@ +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. @@ -6,7 +12,7 @@ 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 `_. @@ -27,7 +33,7 @@ You can also clone a current `development version `_ Tests and Bugs ------------------- +-------------- To run automated tests: 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