/** * Outputs commands for dropping types. * * @param $ofs output file pointer * @param $old_schema original schema * @param $new_schema new schema */ private static function drop_types($ofs, $old_schema, $new_schema) { if ($old_schema != NULL) { foreach (dbx::get_types($old_schema) as $type) { if (!mssql10_schema::contains_type($new_schema, $type['name'])) { $ofs->write(mssql10_type::get_drop_sql($new_schema, $type) . "\n"); } } } }
/** * Returns true if schema contains type with given $name, otherwise false. * * @param $name name of the type * * @return boolean true if schema contains type with given $name, otherwise false. */ public static function contains_type(&$node_schema, $name) { $found = false; foreach (dbx::get_types($node_schema) as $type) { if (strcasecmp($type['name'], $name) == 0) { $found = true; break; } } return $found; }
private static function drop_types($ofs, $old_schema, $new_schema) { if ($old_schema != NULL) { foreach (dbx::get_types($old_schema) as $type) { if (!format_schema::contains_type($new_schema, $type['name'])) { $ofs->write(format_type::get_drop_sql($new_schema, $type) . "\n"); // $ofs->write(mysql5_type::get_type_demotion_sql($new_schema, $type)); } } } }
/** * return regex fragment that can be used to match databases type to enum types */ public static function enum_regex($db_doc) { // enum_type_regex_expression is cached, this function is called a whole lot if ($db_doc !== NULL && self::$enum_type_regex_expression === NULL) { self::$enum_type_regex_expression = ''; $enum_type_names = array(); $schemas =& dbx::get_schemas($db_doc); foreach ($schemas as $schema) { $types =& dbx::get_types($schema); foreach ($types as $type) { if (strcasecmp($type['type'], 'enum') == 0) { $enum_type_names[] = $schema['name'] . '\\.' . $type['name']; } } } self::$enum_type_regex_expression = implode('|', $enum_type_names); if (strlen(self::$enum_type_regex_expression) == 0) { self::$enum_type_regex_expression = 'nevermatchyyyyyyzz'; } } return self::$enum_type_regex_expression; }
/** * Outputs commands for dropping types. * * @param $ofs output file pointer * @param $old_schema original schema * @param $new_schema new schema */ private static function drop_types($ofs, $old_schema, $new_schema) { if ($old_schema != NULL) { foreach (dbx::get_types($old_schema) as $type) { if (!pgsql8_schema::contains_type($new_schema, $type['name'])) { pgsql8::set_context_replica_set_id($type); $ofs->write(pgsql8_type::get_drop_sql($new_schema, $type) . "\n"); } } } }