# HG changeset patch # User Denis Laxalde # Date 1479732299 -3600 # Node ID 7e03f38c8d5fd685ae54fae2297ae907d4b21c4d # Parent 8fb3ab72d7a975bcb972853dc525e07f9671840d# Parent eed83dee2c793eff7b70c4f0c20e279856c55e2f Merge with 3.23 head diff -r 8fb3ab72d7a9 -r 7e03f38c8d5f cubicweb/misc/migration/3.23.0_Any.py --- a/cubicweb/misc/migration/3.23.0_Any.py Mon Nov 21 09:29:52 2016 +0100 +++ b/cubicweb/misc/migration/3.23.0_Any.py Mon Nov 21 13:44:59 2016 +0100 @@ -16,18 +16,18 @@ SELECT DISTINCT tc.table_name, tc.constraint_name FROM information_schema.table_constraints tc, information_schema.key_column_usage kc - WHERE tc.constraint_type IN 'PRIMARY KEY' + WHERE tc.constraint_type = 'PRIMARY KEY' AND kc.table_name = tc.table_name AND kc.table_name LIKE '%\_relation' AND kc.table_schema = tc.table_schema AND kc.constraint_name = tc.constraint_name; '''): - sql('ALTER TABLE %s DROP CONSTRAINT' % (table, cstr)) + sql('ALTER TABLE %s DROP CONSTRAINT %s' % (table, cstr)) for table, cstr in sql(""" SELECT DISTINCT table_name, constraint_name FROM information_schema.constraint_column_usage WHERE table_name LIKE 'cw\_%' AND constraint_name LIKE '%\_key'"""): - sql("ALTER TABLE %(table)s DROP CONSTRAINT %(cstr)s" % locals()) + sql('ALTER TABLE %s DROP CONSTRAINT %s' % (table, cstr)) for rschema in schema.relations(): if rschema.rule or rschema in PURE_VIRTUAL_RTYPES: @@ -36,10 +36,6 @@ for rdef in rschema.rdefs.values(): table = 'cw_{0}'.format(rdef.subject) column = 'cw_{0}'.format(rdef.rtype) - if any(isinstance(cstr, UniqueConstraint) for cstr in rdef.constraints): - old_name = '%s_%s_key' % (table.lower(), column.lower()) - sql('ALTER TABLE %s DROP CONSTRAINT %s' % (table, old_name)) - source.create_index(cnx, table, column, unique=True) if rschema.inlined or rdef.indexed: old_name = '%s_%s_idx' % (table.lower(), column.lower()) sql('DROP INDEX IF EXISTS %s' % old_name)