anchor.diff:  
   restore_backup_db_file(DbName) ->
       DbDir = config:get("couchdb", "database_dir"),
  -    stop(whereis(couch_server_sup)),
  +
  +    {ok, Db} = couch_db:open_int(DbName, []),
  +    ok = couch_db:close(Db),
  +    exit(Db#db.main_pid, shutdown),
  +
       DbFile = filename:join([DbDir, ?b2l(DbName) ++ ".couch"]),
       ok = file:delete(DbFile),
       ok = file:rename(DbFile ++ ".backup", DbFile),
  -    start(),
       ok.
   
   compact_db(DbName) ->
  
positive.code:             couch_mrview_index, DbName, <<"_design/foo">>),
          ?assert(is_pid(IndexerPid)),
          ?assert(is_process_alive(IndexerPid)),
          ?assertEqual(2, count_db_refs(DbName)),
  
          Rows0 = query_view(DbName, "foo", "bar"),
          ?assertEqual(3, length(Rows0)),
          ?assertEqual(2, count_db_refs(DbName)),
          ?assert(is_process_alive(IndexerPid)),
  
          create_doc(DbName, "doc1000"),
          Rows1 = query_view(DbName, "foo", "bar"),
          ?assertEqual(4, length(Rows1)),
          ?assertEqual(2, count_db_refs(DbName)),
          ?assert(is_process_alive(IndexerPid)),
  
          Ref1 = get_db_ref_counter(DbName),
          compact_db(DbName),
          Ref2 = get_db_ref_counter(DbName),
          ?assertEqual(2, couch_ref_counter:count(Ref2)),
          ?assertNotEqual(Ref2, Ref1),
          ?assertNot(is_process_alive(Ref1)),
          ?assert(is_process_alive(IndexerPid)),
  
          compact_view_group(DbName, "foo"),
          ?assertEqual(2, count_db_refs(DbName)),
          Ref3 = get_db_ref_counter(DbName),
          ?assertEqual(Ref3, Ref2),
          ?assert(is_process_alive(IndexerPid)),
  
          create_doc(DbName, "doc1001"),
          Rows2 = query_view(DbName, "foo", "bar"),
          ?assertEqual(5, length(Rows2)),
          ?assertEqual(2, count_db_refs(DbName)),
          ?assert(is_process_alive(IndexerPid))
      end).
  
  
negative.code:     create_design_doc(DbName, <<"_design/foo">>, <<"bar">>),
      DbName.
  
  setup_legacy() ->
      DbName = <<"test">>,
      DbFileName = "test.couch",
      OldDbFilePath = filename:join([?FIXTURESDIR, DbFileName]),
      OldViewName = "3b835456c235b1827e012e25666152f3.view",
      FixtureViewFilePath = filename:join([?FIXTURESDIR, OldViewName]),
      NewViewName = "6cf2c2f766f87b618edf6630b00f8736.view",
  
      DbDir = config:get("couchdb", "database_dir"),
      ViewDir = config:get("couchdb", "view_index_dir"),
      OldViewFilePath = filename:join([ViewDir, ".test_design", OldViewName]),
      NewViewFilePath = filename:join([ViewDir, ".test_design", "mrview",
                                       NewViewName]),
  
      NewDbFilePath = filename:join([DbDir, DbFileName]),
  
      Files = [NewDbFilePath, OldViewFilePath, NewViewFilePath],
  
      %% make sure there is no left over
      lists:foreach(fun(File) -> file:delete(File) end, Files),
  
      % copy old db file into db dir
      {ok, _} = file:copy(OldDbFilePath, NewDbFilePath),
  
      % copy old view file into view dir
      ok = filelib:ensure_dir(OldViewFilePath),
  
      {ok, _} = file:copy(FixtureViewFilePath, OldViewFilePath),
  
      {DbName, Files}.
  
  teardown({DbName, _}) ->
      teardown(DbName);
  teardown(DbName) when is_binary(DbName) ->
      couch_server:delete(DbName, [?ADMIN_CTX]),
      ok.
  
  teardown_legacy({_DbName, Files}) ->
      lists:foreach(fun(File) -> file:delete(File) end, Files).
  
  view_indexes_cleanup_test_() ->
      {
  