当 ravendb 运行托管其他数据库时删除单个 ravendb 数据库

发布于 2024-11-30 00:59:53 字数 148 浏览 1 评论 0原文

当 RavenDB 仍在运行并托管其他数据库时,有什么方法可以删除单个数据库中的所有数据?

在 RavenDB 为不同客户托管多个数据库的生产环境中,为了从单个数据库中删除数据而停止 RavenDB 是不可接受的。是否需要定制开发一个工具来单独删除文档来实现此目的?

Is there any way I can remove all data in a single database while RavenDB is still running, hosting other databases?

In a production environment with RavenDB hosting multiple databases for different customers, it is not acceptable to stop RavenDB in order to delete the data from a single database. Would it be necessary to custom develop a tool, at delete documents individually to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌上青苔 2024-12-07 00:59:53

如果您删除了描述数据库的文档,那么您就阻止了对其的访问。
RavenDB 不提供实际删除数据库的方法,但如果删除描述数据库的文档,数据库将被关闭。
然后,您可以根据需要删除或备份数据库目录。

If you delete the document that describes the database then you have prevented access to it.
RavenDB doesn't provide a way to actually delete the database, but the database would be shut down if you delete the document describing it.
You can then delete the database directory, or back it up, according to your needs.

木森分化 2024-12-07 00:59:53

在版本 2.0.3 中(甚至可能在之前的版本中),工作室正在调用以下 http 端点来删除数据库:

/admin/databases/nameOfYourDatabase?hard-delete=true
?hard-delete=true 是可选的。

根据工作室的源代码,我创建了这个函数:

    public void DeleteDatabase(string name, bool hardDelete = false)
    {
        if (string.IsNullOrEmpty(name))
            throw new ArgumentNullException("name");

        var databaseCommands = _documentStore.DatabaseCommands;
        var relativeUrl = "/admin/databases/" + name;

        if (hardDelete)
            relativeUrl += "?hard-delete=true";

        var serverClient = databaseCommands.ForSystemDatabase() as ServerClient;
        if (serverClient == null)
            throw new ApplicationException("Please use a more intelligent exception here");

        var httpJsonRequest = serverClient.CreateRequest("DELETE", relativeUrl);
        httpJsonRequest.ExecuteRequest();
    }

In version 2.0.3 (maybe even in releases before) the studio is calling the following http endpoint in order to delete a database:

/admin/databases/nameOfYourDatabase?hard-delete=true
?hard-delete=true is optional.

Based on the source code from the studio I have created this function:

    public void DeleteDatabase(string name, bool hardDelete = false)
    {
        if (string.IsNullOrEmpty(name))
            throw new ArgumentNullException("name");

        var databaseCommands = _documentStore.DatabaseCommands;
        var relativeUrl = "/admin/databases/" + name;

        if (hardDelete)
            relativeUrl += "?hard-delete=true";

        var serverClient = databaseCommands.ForSystemDatabase() as ServerClient;
        if (serverClient == null)
            throw new ApplicationException("Please use a more intelligent exception here");

        var httpJsonRequest = serverClient.CreateRequest("DELETE", relativeUrl);
        httpJsonRequest.ExecuteRequest();
    }
写给空气的情书 2024-12-07 00:59:53

我想更新您的解决方案,这是“删除”数据库的唯一解决方案。

实际上在RavenDB的新版本(2.0)中,仍然不稳定,您可以使用新版本的studio删除数据库。

您可以从这里下载: http://hibernatingrhinos.com/builds/ravendb-unstable -v2.0/

我希望这除了 Ayende 好的答案之外还能对您有所帮助。

最好的,
达里奥

I want to update your solution, that are the only solution for "deleting" a database.

Actually in the new version (2.0) of RavenDB, which are still unstable, you can delete a database with the new version of the studio.

You can download it from here: http://hibernatingrhinos.com/builds/ravendb-unstable-v2.0/

I'll hope this help you aditionally to the Ayende good answer.

Best,
Dario

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文