anchor.diff:      {ok, State}.
   
   
  +handle_call({demote, Node}, _From, State) ->
  +    %% Remove a node from the mnesia cluster after it's been disconnected.
  +    {atomic, ok} = mnesia:del_table_copy(schema, Node),
  +    {reply, ok, State};
  +
  +handle_call(demote_self, _From, State) ->
  +    %% Back up, remove the schema from disk, then restart. The
  +    %% initialization routines will handle declustering.
  +    case mnesia:system_info(db_nodes) == [node()]
  +        andalso non_local_tables() == [] of
  +        true ->
  +            %% No-op if it's not a peer
  +            {reply, ok, State};
  +        false ->
  +            backup(),
  +            stopped = mnesia:stop(),
  +            ok = mnesia:delete_schema([node()]),
  +            ?log_info("Demoting. Deleted local schema. Mnesia info:~n~p",
  +                      [mnesia:system_info(all)]),
  +            {ok, State1} = init([]),
  +            {reply, ok, State1}
  +    end;
  +
  +handle_call({promote_self, Node}, _From, State) ->
  +    case mnesia:system_info(db_nodes) of
  +        [N] when N == node() ->
  +            %% Even though we use local_content tables, it's impossible to
  +            %% merge them, so instead we backup and restore.
  +            ?log_info("Promoting this node to a peer.", []),
  +            Tables = backup(),
  +            stopped = mnesia:stop(),
  +            ok = mnesia:delete_schema([node()]),
  +            start_mnesia(),
  +            %% Connect to an existing peer
  +            {ok, [Node]} = mnesia:change_config(extra_db_nodes, [Node]),
  +            %% Write the schema to disk
  +            ensure_schema(),
  +            ?log_info("Restoring tables. Mnesia config:~n~p",
  +                      [mnesia:system_info(all)]),
  +            KeepTables = mnesia:system_info(tables),
  +            CreateTables = Tables -- KeepTables,
  +            %% Restore our old data to the new tables
  +            {atomic, _} = mnesia:restore(
  +                            backup_file(),
  +                            [{keep_tables, KeepTables},
  +                             {recreate_tables, CreateTables}]),
  +            ok = file:delete(backup_file());
  +        _ ->
  +            %% Only promote if we're not already a peer
  +            ?log_error("Attempt to promote even though we're already a peer.",
  +                       []),
  +            ok
  +    end,
  +    {reply, ok, State};
  +
  +handle_call(peers, _From, State) ->
  +    Reply = try mnesia:table_info(config, disc_copies)
  +            catch exit:{aborted, {no_exists, _, _}} -> []
  +            end,
  +    {reply, Reply, State};
  +
   handle_call(prepare_rename, _From, State) ->
  -    Pre = tmpdir("pre_rename"),
  -    Reply = mnesia:backup(Pre),
  -    {reply, Reply, State};
  +    backup(),
  +    {reply, ok, State};
   
   handle_call({ensure_table, TableName, Opts}, _From, State) ->
       try mnesia:table_info(TableName, disc_copies) of
  
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:                     ?log_info("Creating local copy of ~p",
                                [TableName]),
                      {atomic, ok} = mnesia:add_table_copy(
                                       TableName, node(), disc_copies),
                      ok
              end
      catch exit:{aborted, {no_exists, _, _}} ->
              {atomic, ok} =
  