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