Best way to create a voron RavenFS database in code?

138 Views Asked by At

In RavenDB 3.0, i want to create in code a new RavenFS database but in voron engine. When the database doen't exist, it's created but un essent engine.

I tried this way :

FilesStore = new FilesStore
  {
  Url = "http://localhost:8080",
  DefaultFileSystem = "Test_FS"
  };
FilesStore.Initialize();
FilesStore.CreateOrUpdate("Test_FS");

Where Create or update is an extention function :

public static void CreateOrUpdate(this FilesStore filesStore, string databaseName)
    {
        try
        {
                       filesStore.AsyncFilesCommands.Admin.CreateOrUpdateFileSystemAsync(
                new FileSystemDocument
                {
                    Id = "Raven/FileSystem/"+databaseName,
                    Settings =
                {
                    {"Raven/FileSystem/DataDir", "~/FileSystems/" + databaseName},
                    {"Raven/FileSystem/Storage", "voron"},
                    {"Raven/ActiveBundles", ""}
                }
                }).Wait();
        }
        catch (Exception e)
        {
            var ex = e;
            throw;
        }

    }

I have to set the DefaultFileSystem name when i create the FileStore or it will crash during the CreateOrUpdateFileSystemAsync

So the FileStore is created once in essent, then transformed in voron in a second time... Ugly way...

Is there a better way to do this ? Thanks

Whiletrue

0

There are 0 best solutions below