From adfa9bbd04cd3571932ee7675344ca723bfa1eab Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Jul 2012 14:26:23 +0200 Subject: Move indexes from model scope to table scope Conceptually, indexes belong to tables and some databases (MySQL, MSSQL) indeed treat them as such (i.e., you can have indexes with the same name in different tables). --- odb/relational/pgsql/schema.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'odb/relational/pgsql') diff --git a/odb/relational/pgsql/schema.cxx b/odb/relational/pgsql/schema.cxx index c774561..2113894 100644 --- a/odb/relational/pgsql/schema.cxx +++ b/odb/relational/pgsql/schema.cxx @@ -173,9 +173,13 @@ namespace relational virtual string name (sema_rel::index& in) { - // In PostgreSQL indexes cannot have a schema. + // In PostgreSQL, index names are database-global. Make them unique + // by prefixing the index name with table name. Note, however, that + // they cannot be qualified with the schema name. // - return quote_id (in.name ().uname ()); + return quote_id ( + static_cast (in.scope ()).name ().uname () + + "_" + in.name ()); } }; entry create_index_; -- cgit v1.1