From 8295d4bd02946b7bdbff2a9cfa7763232e2d2fd0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Apr 2013 14:34:57 +0200 Subject: Clean up class order in schema generators --- odb/relational/mysql/schema.cxx | 93 ++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 44 deletions(-) (limited to 'odb/relational/mysql/schema.cxx') diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx index 9b04e6b..8e71f92 100644 --- a/odb/relational/mysql/schema.cxx +++ b/odb/relational/mysql/schema.cxx @@ -21,6 +21,7 @@ namespace relational // // Drop. // + struct drop_foreign_key: relational::drop_foreign_key, context { drop_foreign_key (base const& x): base (x) {} @@ -109,6 +110,21 @@ namespace relational }; entry drop_foreign_key_; + struct drop_index: relational::drop_index, context + { + drop_index (base const& x): base (x) {} + + virtual void + drop (sema_rel::index& in) + { + sema_rel::table& t (static_cast (in.scope ())); + + os << "DROP INDEX " << name (in) << " ON " << + quote_id (t.name ()) << endl; + } + }; + entry drop_index_; + // // Create. // @@ -184,6 +200,36 @@ namespace relational }; entry create_foreign_key_; + struct create_index: relational::create_index, context + { + create_index (base const& x): base (x) {} + + virtual void + create (sema_rel::index& in) + { + os << "CREATE "; + + if (!in.type ().empty ()) + os << in.type () << ' '; + + os << "INDEX " << name (in); + + if (!in.method ().empty ()) + os << " USING " << in.method (); + + os << endl + << " ON " << table_name (in) << " ("; + + columns (in); + + os << ")" << endl; + + if (!in.options ().empty ()) + os << ' ' << in.options () << endl; + } + }; + entry create_index_; + struct create_table: relational::create_table, context { create_table (base const& x): base (x) {} @@ -268,50 +314,9 @@ namespace relational }; entry create_table_; - struct create_index: relational::create_index, context - { - create_index (base const& x): base (x) {} - - virtual void - create (sema_rel::index& in) - { - os << "CREATE "; - - if (!in.type ().empty ()) - os << in.type () << ' '; - - os << "INDEX " << name (in); - - if (!in.method ().empty ()) - os << " USING " << in.method (); - - os << endl - << " ON " << table_name (in) << " ("; - - columns (in); - - os << ")" << endl; - - if (!in.options ().empty ()) - os << ' ' << in.options () << endl; - } - }; - entry create_index_; - - struct drop_index: relational::drop_index, context - { - drop_index (base const& x): base (x) {} - - virtual void - drop (sema_rel::index& in) - { - sema_rel::table& t (static_cast (in.scope ())); - - os << "DROP INDEX " << name (in) << " ON " << - quote_id (t.name ()) << endl; - } - }; - entry drop_index_; + // + // Alter. + // struct alter_column: relational::alter_column, context { -- cgit v1.1