-- drop old tables
------------------

DROP TABLE usedweldpoints;
DROP TABLE weldpoints;
DROP TABLE cars;
DROP TABLE subassemblies;

-- create new tables from scratch
---------------------------------

CREATE TABLE cars(
	id serial PRIMARY KEY,
	name varchar(50)
);

CREATE TABLE subassemblies(
	id serial PRIMARY KEY,
	name varchar(50),
	filename_image varchar(100),
	scale_image float,
	pos_x integer,
	pos_y integer,
	pos_z integer,
	dir_x integer,
	dir_y integer,
	dir_z integer
);

CREATE TABLE weldpoints(
	name integer PRIMARY KEY,
	x integer,
	y integer,
	z integer,
	cartype integer REFERENCES cars (id),
	subassembly integer REFERENCES subassemblies (id),
	axe_robot varchar(50),
	technician_tel text
);

CREATE TABLE usedweldpoints(
	name integer REFERENCES weldpoints(name) PRIMARY KEY,
	marked bool
);
