Tarantool development patches archive
 help / color / mirror / Atom feed
From: AKhatskevich <avkhatskevich@tarantool.org>
To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org
Subject: [tarantool-patches] [PATCH 2/3] Allow use existing user
Date: Sat, 23 Jun 2018 00:43:34 +0300	[thread overview]
Message-ID: <9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org> (raw)
In-Reply-To: <cover.1529703268.git.avkhatskevich@tarantool.org>
In-Reply-To: <cover.1529703268.git.avkhatskevich@tarantool.org>

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

  parent reply	other threads:[~2018-06-22 21:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 21:43 [tarantool-patches] [PATCH 0/3][vshard] Small patches AKhatskevich
2018-06-22 21:43 ` [tarantool-patches] [PATCH 1/3] Do not force login/pass in URI AKhatskevich
2018-06-22 22:11   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-25 21:56     ` Alex Khatskevich
2018-06-26 11:11       ` Vladislav Shpilevoy
2018-06-22 21:43 ` AKhatskevich [this message]
2018-06-22 22:12   ` [tarantool-patches] Re: [PATCH 2/3] Allow use existing user Vladislav Shpilevoy
2018-06-25 21:55     ` Alex Khatskevich
2018-06-26 11:11       ` Vladislav Shpilevoy
2018-06-22 21:43 ` [tarantool-patches] [PATCH 3/3] Introduce destroy module feature AKhatskevich
2018-06-22 22:11   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-25 21:54     ` Alex Khatskevich
2018-06-26 11:11       ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org \
    --to=avkhatskevich@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH 2/3] Allow use existing user' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox