Legal action derails pig welfare code