Erlang:多次调用 mnesia:create_schema 会有副作用吗?
在每个应用程序启动时调用 mnesia:create_schema()
是否有副作用?
根据我不断阅读的内容,每个数据库实例只应调用此函数一次。在现有数据库上多次调用它是一个大问题吗?
Is there a side effect to calling mnesia:create_schema()
on each application start?
From what I keep reading, this function should only be called once per database instance. Is it a big issue to call it more than once on an existing database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我之前在开发过程中已经这样做过,它会在已经存在的表上发出警告。但是,我不会在生产中重新运行它,因为它可能会产生一些我不知道的副作用,即使现在没有,也不能保证在未来的版本中不会有。 。
为什么要运行多次?
I've done this before in development and it spits out warnings on the tables that already exist. However I wouldn't make it a practice to rerun it in Production since it's possible that it may have some side-effects I'm unaware of and even if it doesn't now there is no guarantee that it won't in future releases.
Why do you want to run it multiple times?
它没有副作用,但稍后调用将导致 {error, {Node,{already_exists,Node}}}。你可以使用类似的东西
It has no side effect, but later calls will result in {error, {Node,{already_exists,Node}}}. You can use something like
那么它可能会在第二次调用时引发异常。抓住它吧。
Well it could throw an exception on the second call. Just catch it.