# HG changeset patch # User Alexandre Fayolle # Date 1283354473 -7200 # Node ID 2506ab5d82d7926219ee37b782067d4ee6e6f169 # Parent 8af7d755f05fc516e45ef272e9fe165a409faeaf migration actions for unique_together constraints diff -r 8af7d755f05f -r 2506ab5d82d7 __pkginfo__.py --- a/__pkginfo__.py Wed Sep 01 15:56:21 2010 +0200 +++ b/__pkginfo__.py Wed Sep 01 17:21:13 2010 +0200 @@ -43,7 +43,7 @@ 'logilab-common': '>= 0.51.0', 'logilab-mtconverter': '>= 0.8.0', 'rql': '>= 0.26.2', - 'yams': '>= 0.29.1', + 'yams': '>= 0.30.0', 'docutils': '>= 0.6', #gettext # for xgettext, msgcat, etc... # web dependancies @@ -52,7 +52,7 @@ 'Twisted': '', # XXX graphviz # server dependencies - 'logilab-database': '>= 1.1.0', + 'logilab-database': '>= 1.2.0', 'pysqlite': '>= 2.5.5', # XXX install pysqlite2 } diff -r 8af7d755f05f -r 2506ab5d82d7 debian/control --- a/debian/control Wed Sep 01 15:56:21 2010 +0200 +++ b/debian/control Wed Sep 01 17:21:13 2010 +0200 @@ -33,7 +33,7 @@ Conflicts: cubicweb-multisources Replaces: cubicweb-multisources Provides: cubicweb-multisources -Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.1.0), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2 +Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), cubicweb-ctl (= ${source:Version}), python-logilab-database (>= 1.2.0), cubicweb-postgresql-support | cubicweb-mysql-support | python-pysqlite2 Recommends: pyro, cubicweb-documentation (= ${source:Version}) Description: server part of the CubicWeb framework CubicWeb is a semantic web application framework. @@ -97,7 +97,7 @@ Package: cubicweb-common Architecture: all XB-Python-Version: ${python:Versions} -Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.8.0), python-logilab-common (>= 0.51.0), python-yams (>= 0.29.1), python-rql (>= 0.26.3), python-lxml +Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.8.0), python-logilab-common (>= 0.51.0), python-yams (>= 0.30.0), python-rql (>= 0.26.3), python-lxml Recommends: python-simpletal (>= 4.0), python-crypto Conflicts: cubicweb-core Replaces: cubicweb-core diff -r 8af7d755f05f -r 2506ab5d82d7 server/migractions.py --- a/server/migractions.py Wed Sep 01 15:56:21 2010 +0200 +++ b/server/migractions.py Wed Sep 01 17:21:13 2010 +0200 @@ -1117,6 +1117,34 @@ if commit: self.commit() + def cmd_add_unique_together_attrs(self, etype, attrlist, commit=True): + """ + Add a (sql) UNIQUE index on all the underlying columns for the + attributes listed in attrlist. That list can also contain + inlined relations. + """ + prefix = SQL_PREFIX + dbhelper = self.repo.system_source.dbhelper + cols = ['%s%s' % (prefix, col) for col in attrlist] + table = '%s%s' % (prefix, etype) + sql = dbhelper.sql_create_multicol_unique_index(table, cols) + self.sqlexec(sql, ask_confirm=False) + if commit: + self.commit() + + def cmd_drop_unique_together_attrs(self, etype, attrlist, commit=True): + """ + remove a UNIQUE index created with add_unique_together_attrs + """ + prefix = SQL_PREFIX + dbhelper = self.repo.system_source.dbhelper + cols = ['%s%s' % (prefix, col) for col in attrlist] + table = '%s%s' % (prefix, etype) + sql = dbhelper.sql_drop_multicol_unique_index(table, cols) + self.sqlexec(sql, ask_confirm=False) + if commit: + self.commit() + @deprecated('[3.2] use sync_schema_props_perms(ertype, syncprops=False)') def cmd_synchronize_permissions(self, ertype, commit=True): self.cmd_sync_schema_props_perms(ertype, syncprops=False, commit=commit)