0

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.

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++ } \
}

1 Answer 1

2

Our team use

perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g'
1
  • 1
    Thanks. That's much neater!
    – Jern
    Commented Dec 2, 2021 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.