-- Adminer 4.8.1 PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) dump

DROP TABLE IF EXISTS "driver";
DROP SEQUENCE IF EXISTS driver_id_seq;
CREATE SEQUENCE driver_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."driver" (
    "id" integer DEFAULT nextval('driver_id_seq') NOT NULL,
    "name" character varying NOT NULL,
    CONSTRAINT "driver_pkey" PRIMARY KEY ("id")
) WITH (oids = false);

INSERT INTO "driver" ("id", "name") VALUES
(1,	'default');

DROP TABLE IF EXISTS "track";
DROP SEQUENCE IF EXISTS track_id_seq;
CREATE SEQUENCE track_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."track" (
    "id" integer DEFAULT nextval('track_id_seq') NOT NULL,
    "trackName" character varying(200),
    "vehicle_id" integer NOT NULL,
    "driver_id" integer NOT NULL,
    "date" date,
    "distance" double precision NOT NULL,
    "speed" double precision NOT NULL,
    CONSTRAINT "track_pkey" PRIMARY KEY ("id")
) WITH (oids = false);


DROP TABLE IF EXISTS "vehicle";
DROP SEQUENCE IF EXISTS vehicle_id_seq;
CREATE SEQUENCE vehicle_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."vehicle" (
    "id" integer DEFAULT nextval('vehicle_id_seq') NOT NULL,
    "name" character varying NOT NULL,
    "licenseplate" character varying,
    CONSTRAINT "vehicle_pkey" PRIMARY KEY ("id")
) WITH (oids = false);

INSERT INTO "vehicle" ("id", "name", "licenseplate") VALUES
(1,	'default',	'default');

DROP TABLE IF EXISTS "waypoint";
DROP SEQUENCE IF EXISTS waypoint_id_seq;
CREATE SEQUENCE waypoint_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."waypoint" (
    "id" integer DEFAULT nextval('waypoint_id_seq') NOT NULL,
    "lat" double precision NOT NULL,
    "lon" double precision NOT NULL,
    "ele" double precision NOT NULL,
    "speed" double precision,
    "time" timestamp,
    "track_id" integer NOT NULL,
    CONSTRAINT "waypoint_pkey" PRIMARY KEY ("id")
) WITH (oids = false);


ALTER TABLE ONLY "public"."track" ADD CONSTRAINT "track_driver_id_fkey" FOREIGN KEY (driver_id) REFERENCES driver(id) NOT DEFERRABLE;
ALTER TABLE ONLY "public"."track" ADD CONSTRAINT "track_vehicle_id_fkey" FOREIGN KEY (vehicle_id) REFERENCES vehicle(id) NOT DEFERRABLE;

ALTER TABLE ONLY "public"."waypoint" ADD CONSTRAINT "waypoint_track_id_fkey" FOREIGN KEY (track_id) REFERENCES track(id) NOT DEFERRABLE;

-- 2025-01-16 09:13:38.732525+00