-- PostgreSQL CSV imports.
-- Palaist no psql sesijas mapē, kur atrodas CSV faili, vai pielāgot absolūtos ceļus.

TRUNCATE TABLE work_items, work_subsections, work_sections, measurement_units, construction_objects RESTART IDENTITY CASCADE;

\copy construction_objects (object_id, object_name, partner_name, notes) FROM 'construction_objects.csv' WITH (FORMAT csv, HEADER true, ENCODING 'UTF8');
\copy measurement_units (unit_id, unit_code, unit_name, notes) FROM 'measurement_units.csv' WITH (FORMAT csv, HEADER true, ENCODING 'UTF8');
\copy work_sections (section_id, object_id, section_code, section_name, sort_order, notes) FROM 'work_sections.csv' WITH (FORMAT csv, HEADER true, ENCODING 'UTF8');
\copy work_subsections (subsection_id, section_id, subsection_code, subsection_name, sort_order, notes) FROM 'work_subsections.csv' WITH (FORMAT csv, HEADER true, ENCODING 'UTF8');
\copy work_items (item_id, subsection_id, position_code, position_detail, work_description, unit_id, quantity, price_ls, sort_order, notes) FROM 'work_items.csv' WITH (FORMAT csv, HEADER true, ENCODING 'UTF8');
