Migration from attr_encrypted to vault-rails gem












0















Earlier my code was having encryption methodology using 'attr_encrypted' but later I changed my mind to integrate vault for encryption/decryption. So I want to understand how can I migrate my old saved encrypted data to new one.










share|improve this question





























    0















    Earlier my code was having encryption methodology using 'attr_encrypted' but later I changed my mind to integrate vault for encryption/decryption. So I want to understand how can I migrate my old saved encrypted data to new one.










    share|improve this question



























      0












      0








      0








      Earlier my code was having encryption methodology using 'attr_encrypted' but later I changed my mind to integrate vault for encryption/decryption. So I want to understand how can I migrate my old saved encrypted data to new one.










      share|improve this question
















      Earlier my code was having encryption methodology using 'attr_encrypted' but later I changed my mind to integrate vault for encryption/decryption. So I want to understand how can I migrate my old saved encrypted data to new one.







      ruby-on-rails attr-encrypted






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 22 '18 at 17:02









      Daniel Mann

      39.1k66086




      39.1k66086










      asked Nov 20 '18 at 10:28









      Rahul TibrewalRahul Tibrewal

      595




      595
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Seems pretty straightforward. If you have, say, field ssn



          attr_encrypted :ssn


          You can create a second field, now backed by vault



          vault_attribute :ssn2


          Then iterate your records and set ssn2 value to that of ssn. This should take care of data migration.



          After that is done, you might want to delete ssn's backing fields and rename ssn2's backing field(s), so that rest of your code continues to use name ssn.






          share|improve this answer
























          • Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

            – Rahul Tibrewal
            Nov 27 '18 at 11:16













          • @RahulTibrewal: that's a different question.

            – Sergio Tulentsev
            Nov 27 '18 at 11:18











          • I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

            – Rahul Tibrewal
            Nov 27 '18 at 11:30













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390972%2fmigration-from-attr-encrypted-to-vault-rails-gem%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Seems pretty straightforward. If you have, say, field ssn



          attr_encrypted :ssn


          You can create a second field, now backed by vault



          vault_attribute :ssn2


          Then iterate your records and set ssn2 value to that of ssn. This should take care of data migration.



          After that is done, you might want to delete ssn's backing fields and rename ssn2's backing field(s), so that rest of your code continues to use name ssn.






          share|improve this answer
























          • Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

            – Rahul Tibrewal
            Nov 27 '18 at 11:16













          • @RahulTibrewal: that's a different question.

            – Sergio Tulentsev
            Nov 27 '18 at 11:18











          • I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

            – Rahul Tibrewal
            Nov 27 '18 at 11:30


















          0














          Seems pretty straightforward. If you have, say, field ssn



          attr_encrypted :ssn


          You can create a second field, now backed by vault



          vault_attribute :ssn2


          Then iterate your records and set ssn2 value to that of ssn. This should take care of data migration.



          After that is done, you might want to delete ssn's backing fields and rename ssn2's backing field(s), so that rest of your code continues to use name ssn.






          share|improve this answer
























          • Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

            – Rahul Tibrewal
            Nov 27 '18 at 11:16













          • @RahulTibrewal: that's a different question.

            – Sergio Tulentsev
            Nov 27 '18 at 11:18











          • I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

            – Rahul Tibrewal
            Nov 27 '18 at 11:30
















          0












          0








          0







          Seems pretty straightforward. If you have, say, field ssn



          attr_encrypted :ssn


          You can create a second field, now backed by vault



          vault_attribute :ssn2


          Then iterate your records and set ssn2 value to that of ssn. This should take care of data migration.



          After that is done, you might want to delete ssn's backing fields and rename ssn2's backing field(s), so that rest of your code continues to use name ssn.






          share|improve this answer













          Seems pretty straightforward. If you have, say, field ssn



          attr_encrypted :ssn


          You can create a second field, now backed by vault



          vault_attribute :ssn2


          Then iterate your records and set ssn2 value to that of ssn. This should take care of data migration.



          After that is done, you might want to delete ssn's backing fields and rename ssn2's backing field(s), so that rest of your code continues to use name ssn.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 10:53









          Sergio TulentsevSergio Tulentsev

          182k30292308




          182k30292308













          • Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

            – Rahul Tibrewal
            Nov 27 '18 at 11:16













          • @RahulTibrewal: that's a different question.

            – Sergio Tulentsev
            Nov 27 '18 at 11:18











          • I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

            – Rahul Tibrewal
            Nov 27 '18 at 11:30





















          • Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

            – Rahul Tibrewal
            Nov 27 '18 at 11:16













          • @RahulTibrewal: that's a different question.

            – Sergio Tulentsev
            Nov 27 '18 at 11:18











          • I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

            – Rahul Tibrewal
            Nov 27 '18 at 11:30



















          Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

          – Rahul Tibrewal
          Nov 27 '18 at 11:16







          Need a bit correction, I want to use both the mechanism, if someone data is already saved using attr_encrypted then use that and vault for new user or any old user is updating their data.

          – Rahul Tibrewal
          Nov 27 '18 at 11:16















          @RahulTibrewal: that's a different question.

          – Sergio Tulentsev
          Nov 27 '18 at 11:18





          @RahulTibrewal: that's a different question.

          – Sergio Tulentsev
          Nov 27 '18 at 11:18













          I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

          – Rahul Tibrewal
          Nov 27 '18 at 11:30







          I have added a new question, can you please have a look on it? stackoverflow.com/questions/53498689/…

          – Rahul Tibrewal
          Nov 27 '18 at 11:30






















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390972%2fmigration-from-attr-encrypted-to-vault-rails-gem%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()