Changes the sql code and schema to fix the error in sql insert