[tarantool-patches] [PATCH 2/3] Allow use existing user
AKhatskevich
avkhatskevich at tarantool.org
Sat Jun 23 00:43:34 MSK 2018
This commit allows to create vshard user outside of vshard.
This feature is tested in the next commit (destroy).
Closes #52
---
vshard/storage/init.lua | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua
index 57076e1..059e705 100644
--- a/vshard/storage/init.lua
+++ b/vshard/storage/init.lua
@@ -138,11 +138,19 @@ end
--------------------------------------------------------------------------------
-- Schema
--------------------------------------------------------------------------------
+local function create_user(username, password)
+ box.schema.user.create(username, {
+ password = password,
+ if_not_exists = true,
+ })
+ -- Replication may has not been granted, if user exists.
+ box.schema.user.grant(username, 'replication', nil, nil,
+ {if_not_exists = true})
+end
local function storage_schema_v1(username, password)
log.info("Initializing schema")
- box.schema.user.create(username, {password = password})
- box.schema.user.grant(username, 'replication')
+ create_user(username, password)
local bucket = box.schema.space.create('_bucket')
bucket:format({
--
2.14.1
More information about the Tarantool-patches
mailing list