docs: def _reorder_types(self, types_script):
          """
          Takes type scripts and reorders them to avoid Type doesn't exist exception
          """
          self._logger.debug('Running types definitions scripts')
          self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions')
          _type_statements = sqlparse.split(types_script)
          # TODO: move up to classes
          _type_statements_dict = {}  # dictionary that store statements with type and order.
          type_unordered_scripts = []  # scripts to execute without order
          type_drop_scripts = []  # drop scripts to execute first
          for _type_statement in _type_statements:
              _type_statement_parsed = sqlparse.parse(_type_statement)
              if len(_type_statement_parsed) > 0:  # can be empty parsed object so need to check
                  # we need only type declarations to be ordered
                  if _type_statement_parsed[0].get_type() == 'CREATE':
                      _type_body_r = r'\bcreate\s+\b(?:type|domain)\s+\b(\w+\.\w+|\w+)\b'
                      _type_name = re.compile(_type_body_r, flags=re.IGNORECASE).findall(_type_statement)[0]
                      _type_statements_dict[str(_type_name)] = \
                          {'script': _type_statement, 'deps': []}
                  elif _type_statement_parsed[0].get_type() == 'DROP':
                      type_drop_scripts.append(_type_statement)
                  else:
                      type_unordered_scripts.append(_type_statement)
          # now let's add dependant types to dictionary with types
          # _type_statements_list = []  # list of statements to be ordered
          for _type_key in _type_statements_dict.keys():
              for _type_key_sub, _type_value in _type_statements_dict.items():
                  if _type_key != _type_key_sub:
                      if pgpm.lib.utils.misc.find_whole_word(_type_key)(_type_value['script']):
                          _type_value['deps'].append(_type_key)
          # now let's add order to type scripts and put them ordered to list
          _deps_unresolved = True
          _type_script_order = 0
          _type_names = []
          type_ordered_scripts = []  # ordered list with scripts to execute
          while _deps_unresolved:
              for k, v in _type_statements_dict.items():
                  if not v['deps']:
                      _type_names.append(k)
                      v['order'] = _type_script_order
                      _type_script_order += 1
                      if not v['script'] in type_ordered_scripts:
                          type_ordered_scripts.append(v['script'])
                  else:
                      _dep_exists = True
                      for _dep in v['deps']:
                          if _dep not in _type_names:
                              _dep_exists = False
                      if _dep_exists:
                          _type_names.append(k)
                          v['order'] = _type_script_order
                          _type_script_order += 1
                          if not v['script'] in type_ordered_scripts:
                              type_ordered_scripts.append(v['script'])
                      else:
                          v['order'] = -1
              _deps_unresolved = False
              for k, v in _type_statements_dict.items():
                  if v['order'] == -1:
                      _deps_unresolved = True
          return type_drop_scripts, type_ordered_scripts, type_unordered_scripts