title: Migration from Postgres to MongoDB
body: <p>Need better solution for migration.</p>
  
  <p><strong>Description</strong>: Service for user mail address verification.</p>
  
  <p><strong>Problem</strong>: Business logic stored in pl/pgSQL procedures in Postgres.</p>
  
  <p><strong>Steps</strong>:</p>
  
  <pre><code>1. Insert into table user Email address and randomly generated hash
  
  2. Send verification/confirmation Email with URL path and hash argument
  
  3. Recv HTTP request with hash:
      hash equals - Update record: CONFIRMED, return success
      hash not found - Return error
  
  4. Send response (error or success HTML page)
  </code></pre>
  
  <p><strong>Details with servlet logic (Steps 3,4):</strong></p>
  
  <pre><code>-Servlet call pl/pgSQL procedure with received hash as argument
  
  -Postgres stored procedure doing:
    SELECT record by hash
    if FOUND
      DELETE temporary hash data
      UPDATE email address as verified
      return FOUND
    if NOT_FOUND
      return NOT_FOUND
  
  -Servlet return success or fail HTML page.
  </code></pre>
  
  <p>As I think, with mongoDB migration, I need move some logic from pl/pgSQL procedures to java Servlet.</p>
  
  <p>Is it right?</p>