anchor.diff:              end;
           true ->
               ?log_info("Using existing disk schema on ~p.", [Nodes])
  +    end,
  +    %% Lay down copies of all the tables.
  +    Tables = mnesia:system_info(tables) -- [schema],
  +    ?log_info("Creating local copy of ~p", [Tables]),
  +    lists:foreach(
  +      fun (Table) ->
  +              try mnesia:add_table_copy(Table, node(), disc_copies) of
  +                  {atomic, ok} -> ok
  +              catch E:R ->
  +                      ?log_info("Error creating local copy of ~p: ~p",
  +                                [Table, {E, R}])
  +              end
  +      end, Tables),
  +    ok = mnesia:wait_for_tables(Tables, 2500).
  +
  +
  +%% @doc List of tables that aren't local_content.
  +non_local_tables() ->
  +    [Table || Table <- mnesia:system_info(tables),
  +              Table /= schema,
  +              not mnesia:table_info(Table, local_content)].
  +
  +
  +%% @doc Return yes or no depending on if mnesia is running, or {error,
  +%% Reason} if something is wrong.
  +is_mnesia_running() ->
  +    case mnesia:wait_for_tables([schema], 2500) of
  +        ok ->
  +            yes;
  +        {error, {node_not_running, _}} ->
  +            no;
  +        E -> E
       end.
  +
  +
  +%% @doc Start mnesia and wait for it to come up.
  +start_mnesia() ->
  +    ok = mnesia:start(),
  +    {ok, _} = mnesia:subscribe(system),
  +    {ok, _} = mnesia:subscribe({table, schema, detailed}),
  +    ok = mnesia:wait_for_tables([schema], 30000).
   
   
   %% @doc Hack.
  
positive.code:     ok.
  
  
  %% @doc Make sure we have a disk copy of the schema.
  ensure_schema() ->
      %% Create a new on-disk schema if one doesn't already exist
      Nodes = mnesia:table_info(schema, disc_copies),
  
negative.code:     gen_server:call(?MODULE, {ensure_table, TableName, Opts}).
  
  
  %% @doc Get the list of peer nodes. Returns empty if we're not one;
  %% someone else is responsible for remembering who to talk to in that
  %% case.
  peers() ->
      %% We run this in the server process to make sure mnesia is
      %% actually up.
      gen_server:call(?MODULE, peers).
  
  
  %% @doc Back up the database in preparation for a node rename.
  prepare_rename() ->
      gen_server:call(?MODULE, prepare_rename).
  