anchor.diff:  -module(schematool_admin).
   -export(
      [install/1,
  +    uninstall/0,
  +    is_installed/0,
       candidate_schemas/0,
       load_schema_def/1,
       load_schema_definition/1,
  
positive.code:        end).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% Lookup the current schema (key) in use. Fails if no schema installed.
  
  current_schema() ->
      wait_for_mnesia(),
  
negative.code: 				    value=Schema_key}).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% Delete the current installed schema, that is, all tables.
  %%
  %% Our approach: load an empty schema, migrate to it. Zap.
  %%
  %% This is probably just suitable for testing.
  %%
  %% DANGEROUS - you need to run ?MODULE:allow_full_delete(true) before
  %%  this operation is permitted
  
  delete() ->
      case current_schema() of
  	undefined ->
  	    ok;
  	CurrKey ->
  	    case full_delete_allowed() of
  		true ->
  		    EmptySchema = [],
  		    EmptyKey = load_schema_def(EmptySchema),
  		    migrate_schema(CurrKey, EmptyKey);
  		false ->
  		    {error, delete_not_allowed}
  	    end
      end.
  
  full_delete_allowed() ->
      ?txn_or_err(
         begin
  	   [#schematool_config{value=Bool}] = mnesia:read(schematool_config, full_delete_allowed),
  	   Bool
         end,
         fun(_Err) ->
  	       false
         end).
  
  allow_full_delete(Bool) when Bool == true ;	Bool == false ->
      ?txn(mnesia:write(#schematool_config{key=full_delete_allowed, value=Bool})).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  %% The default schema file of module is module.schema.term
  
  