Clean database with truncation only when necessary