create table __schema__
( target_namespace text not null,
  schema_id text not null,
  internal_schema_id bigint not null,
  schema_definition text not null,
  deleted boolean not null default false,
  timestamp timestamp);
create index __schema__index__ on __schema__
( target_namespace, schema_id, internal_schema_id, deleted );

create table __element__
( element_namespace text not null,
  element_name text not null,
  element_internal_schema_id bigint not null,
  type_namespace text not null,
  type_name text not null,
  type_internal_schema_id bigint not null,
  deleted boolean not null default false,
  timestamp timestamp );
create index __element__index__ on __element__
( element_namespace, element_name, element_internal_schema_id,
  type_internal_schema_id, deleted );

create table __type__
( type_namespace text not null,
  type_name text not null,
  schema_uri text not null,
  internal_schema_id bigint not null,
  deleted boolean not null default false,
  timestamp timestamp );
create index __type__index__ on __type__
( type_namespace, type_name, schema_uri, deleted );

create table __universal_name_alias__
( namespace text not null,
  local_name text not null,
  id_number integer unique,
  id text not null,
  alias text not null,
  deleted boolean not null default false,
  timestamp timestamp );
create index __universal_name_alias__index__ on __universal_name_alias__index__
( namespace, local_name, id_number, id, alias, deleted );

create table __coord_trans__
( id text,
  source_coord text,
  target_coord text,
  source_dimension integer not null,
  target_dimension integer not null,
  method text not null,
  value text,
  trans_error text,
  deleted boolean not null default false );
create index __coord_trans__index__ on __coord_trans__
( id, source_coord, target_coord,
  source_dimension, target_dimension, deleted );

create table __transaction_log__
( id integer not null,
  uri text not null,
  timestamp timestamp,
  request_from text,
  type text,
  info text);
create index __transaction_log__index__ on __transaction_log__
( id, uri );
