From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 23AE124A1C for ; Mon, 25 Jun 2018 17:56:02 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3PCR13uDkGc0 for ; Mon, 25 Jun 2018 17:56:02 -0400 (EDT) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id D7BD42468C for ; Mon, 25 Jun 2018 17:56:01 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 2/3] Allow use existing user References: <9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org> <4d20128b-9199-739a-83e4-3eacfa03465a@tarantool.org> From: Alex Khatskevich Message-ID: <3ef155eb-a465-b96b-e0b8-736db5c758a1@tarantool.org> Date: Tue, 26 Jun 2018 00:55:55 +0300 MIME-Version: 1.0 In-Reply-To: <4d20128b-9199-739a-83e4-3eacfa03465a@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Vladislav Shpilevoy , tarantool-patches@freelists.org >> @@ -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) > > 1. Please, just inline this function. It is not needed anywhere else > and is extremely simple. > done