How, do you upload into PostGIS? It's important, because there are several different ways doing it using Qgis.
Also, if the problem with geometry (common thing if it came from AutoCAD or other CAD software) you can try to fix it before upload using "Fix geometry". algorithm in Processing panel of Qgis.
SELECTST_AsText(ST_LineMerge( ST_GeomFromText('MULTILINESTRING((-29 -27,1 2),(-29 -27,-45 -33),(-45 -33,-46 -32))')) ); т.е. чтоб это вот не собиралось в одну линию путем переворачивания первого сегмента.