Answers.Body: <p>Our team use</p>
  <pre><code>perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g'
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-02T20:18:23.587Z
Answers.Text: Thanks. That's much neater!
Answers.UserDisplayName: Jern
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-02T19:01:33.850Z
Answers.LastActivityDate: 2021-12-02T19:01:33.850Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I had a problem importing a database dump because of some trigger errors. I'm not sure exactly what caused these errors (may have had something to do with custom case activities, which we use quite a lot, or possibly CiviRules).</p>
  <p>I tried deleting the triggers from the dump file using the awk script below, and then imported the new de-triggered dump file. Is there anything wrong with this approach? It seemed to work for me.</p>
  <p>Btw I adapted the awk code from a post on <a href="https://superuser.com/questions/858242/text-deletion-between-patterns-across-multiple-lines-with-respect-to-text-inside">this page</a>.</p>
  <p>Run the awk script as follows: <br />awk -f scriptfilename databasefilename &gt; outputfilename</p>
  <p>awk script:</p>
  <pre><code>BEGIN { curr=0 } \
    /^DELIMITER ;;$/ { in_block=1; del_block=0 } \
    /^DELIMITER ;$/ { in_block=0; blockend=1 } \
    /TRIGGER/ { if (in_block==1) { del_block=1 } } \
    { if (in_block==0) \
      { if (blockend==0) \
        # Neither in a block nor block end reached.
        # Just print the line
        { print } \
      else { \
        # End of a block reached. Do block end handling
        # just this one time. Block end flag off
        blockend=0
          if (del_block==1) \
            { # delete the block. Just throw away the lines
            # in the lines array
            curr=0 } \
          else \
            { # End of block and no delete. Print it out
            for (i=0; i&lt;curr; i++) { print line[i] }
            print # Print the &lt;/script&gt; line
            # use line-array for the next block
           curr=0 \
         } \
       } \
     } \
   else \
     { # In a block. Save the current line for later
      line[curr]=$0
      curr++ } \
  }
  </code></pre>
  
Tags: <database><trigger>
Title: Unable to import database dump - triggers
ThreadText: # Unable to import database dump - triggers
  
  (Asked by: username_0 on 2021-12-02)
  
  I had a problem importing a database dump because of some trigger errors. I'm not sure exactly what caused these errors (may have had something to do with custom case activities, which we use quite a lot, or possibly CiviRules).
  
  I tried deleting the triggers from the dump file using the awk script below, and then imported the new de-triggered dump file. Is there anything wrong with this approach? It seemed to work for me.
  
  Btw I adapted the awk code from a post on [this page](https://superuser.com/questions/858242/text-deletion-between-patterns-across-multiple-lines-with-respect-to-text-inside).
  
  Run the awk script as follows:   
  awk -f scriptfilename databasefilename > outputfilename
  
  awk script:
  
  ```
  BEGIN { curr=0 } \
    /^DELIMITER ;;$/ { in_block=1; del_block=0 } \
    /^DELIMITER ;$/ { in_block=0; blockend=1 } \
    /TRIGGER/ { if (in_block==1) { del_block=1 } } \
    { if (in_block==0) \
      { if (blockend==0) \
        # Neither in a block nor block end reached.
        # Just print the line
        { print } \
      else { \
        # End of a block reached. Do block end handling
        # just this one time. Block end flag off
        blockend=0
          if (del_block==1) \
            { # delete the block. Just throw away the lines
            # in the lines array
            curr=0 } \
          else \
            { # End of block and no delete. Print it out
            for (i=0; i<curr; i++) { print line[i] }
            print # Print the </script> line
            # use line-array for the next block
           curr=0 \
         } \
       } \
     } \
   else \
     { # In a block. Save the current line for later
      line[curr]=$0
      curr++ } \
  }
  
  ```
  
  **Tags:** database, trigger
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-02. Score: 2 | Accepted answer
  
  Our team use
  
  ```
  perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g'
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks. That's much neater!  
  
  ---
  
  