-- Adminer 4.3.1 PostgreSQL dump

\connect "postgres";

DROP TABLE IF EXISTS "spatial_ref_sys";
CREATE TABLE "public"."spatial_ref_sys" (
    "srid" integer NOT NULL,
    "auth_name" character varying(256),
    "auth_srid" integer,
    "srtext" character varying(2048),
    "proj4text" character varying(2048),
    CONSTRAINT "spatial_ref_sys_pkey" PRIMARY KEY ("srid")
) WITH (oids = false);


DROP VIEW IF EXISTS "geography_columns";
CREATE TABLE "geography_columns" ("f_table_catalog" name, "f_table_schema" name, "f_table_name" name, "f_geography_column" name, "coord_dimension" integer, "srid" integer, "type" text);


DROP VIEW IF EXISTS "geometry_columns";
CREATE TABLE "geometry_columns" ("f_table_catalog" character varying(256), "f_table_schema" name, "f_table_name" name, "f_geometry_column" name, "coord_dimension" integer, "srid" integer, "type" character varying(30));


DROP VIEW IF EXISTS "raster_columns";
CREATE TABLE "raster_columns" ("r_table_catalog" name, "r_table_schema" name, "r_table_name" name, "r_raster_column" name, "srid" integer, "scale_x" double precision, "scale_y" double precision, "blocksize_x" integer, "blocksize_y" integer, "same_alignment" boolean, "regular_blocking" boolean, "num_bands" integer, "pixel_types" text[], "nodata_values" double precision[], "out_db" boolean[], "extent" geometry, "spatial_index" boolean);


DROP VIEW IF EXISTS "raster_overviews";
CREATE TABLE "raster_overviews" ("o_table_catalog" name, "o_table_schema" name, "o_table_name" name, "o_raster_column" name, "r_table_catalog" name, "r_table_schema" name, "r_table_name" name, "r_raster_column" name, "overview_factor" integer);


DROP TABLE IF EXISTS "detections";
CREATE SEQUENCE detections_detection_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."detections" (
    "detection_id" integer DEFAULT nextval('detections_detection_id_seq') NOT NULL,
    "snapshot_id" integer,
    "type" detection_type,
    "pos" geometry(PointZ),
    "bbox" box,
    "class" detection_class DEFAULT Unknown,
    "handle" integer DEFAULT -1,
    "best_bbox" box,
    "best_bbox_old" box,
    "bbox3d" box3d,
    "rot" geometry,
    "coverage" real DEFAULT 0.0,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "detections_pkey" PRIMARY KEY ("detection_id"),
    CONSTRAINT "detections_snapshot_fkey" FOREIGN KEY (snapshot_id) REFERENCES snapshots(snapshot_id) ON DELETE CASCADE NOT DEFERRABLE
) WITH (oids = false);


DROP TABLE IF EXISTS "runs";
CREATE SEQUENCE runs_run_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."runs" (
    "run_id" integer DEFAULT nextval('runs_run_id_seq') NOT NULL,
    "runguid" uuid,
    "archivepath" text,
    "localpath" text,
    "session_id" integer DEFAULT 1,
    "instance_id" integer DEFAULT 0,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "runs_pkey" PRIMARY KEY ("run_id"),
    CONSTRAINT "runs_instance_fkey" FOREIGN KEY (instance_id) REFERENCES instances(instance_id) NOT DEFERRABLE,
    CONSTRAINT "runs_session_fkey" FOREIGN KEY (session_id) REFERENCES sessions(session_id) ON DELETE CASCADE NOT DEFERRABLE
) WITH (oids = false);


DROP TABLE IF EXISTS "sessions";
CREATE SEQUENCE sessions_session_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."sessions" (
    "session_id" integer DEFAULT nextval('sessions_session_id_seq') NOT NULL,
    "name" text,
    "start" timestamptz,
    "end" timestamptz,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "sessions_name_key" UNIQUE ("name"),
    CONSTRAINT "sessions_pkey" PRIMARY KEY ("session_id")
) WITH (oids = false);


DROP TABLE IF EXISTS "snapshots";
CREATE SEQUENCE snapshots_snapshot_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."snapshots" (
    "snapshot_id" integer DEFAULT nextval('snapshots_snapshot_id_seq') NOT NULL,
    "run_id" integer,
    "version" integer,
    "imagepath" text,
    "timestamp" timestamptz,
    "timeofday" time without time zone,
    "currentweather" weather,
    "camera_pos" geometry(PointZ),
    "camera_direction" geometry,
    "camera_fov" real,
    "view_matrix" double precision[],
    "proj_matrix" double precision[],
    "processed" boolean DEFAULT false NOT NULL,
    "width" integer,
    "height" integer,
    CONSTRAINT "snapshots_pkey" PRIMARY KEY ("snapshot_id"),
    CONSTRAINT "snapshots_run_fkey" FOREIGN KEY (run_id) REFERENCES runs(run_id) ON DELETE CASCADE NOT DEFERRABLE
) WITH (oids = false);


DROP TABLE IF EXISTS "instances";
CREATE SEQUENCE instances_instance_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."instances" (
    "instance_id" integer DEFAULT nextval('instances_instance_id_seq') NOT NULL,
    "hostname" text,
    "instanceid" text,
    "instancetype" text,
    "publichostname" text,
    "amiid" text,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "instance_info_uniq" UNIQUE ("hostname", "instanceid", "instancetype", "publichostname", "amiid"),
    CONSTRAINT "instanceid_uniq" UNIQUE ("instanceid"),
    CONSTRAINT "isntances_pkey" PRIMARY KEY ("instance_id")
) WITH (oids = false);


DROP TABLE IF EXISTS "snapshot_weathers";
CREATE SEQUENCE snapshot_weathers_weather_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."snapshot_weathers" (
    "weather_id" integer DEFAULT nextval('snapshot_weathers_weather_id_seq') NOT NULL,
    "snapshot_id" integer,
    "weather_type" weather,
    "snapshot_page" integer,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "snapshot_weathers_pkey" PRIMARY KEY ("weather_id"),
    CONSTRAINT "snapshot_weathers_snapshot_id_fkey" FOREIGN KEY (snapshot_id) REFERENCES snapshots(snapshot_id) ON DELETE CASCADE NOT DEFERRABLE
) WITH (oids = false);


DROP TABLE IF EXISTS "uploads";
CREATE SEQUENCE uploads_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."uploads" (
    "id" integer DEFAULT nextval('uploads_id_seq') NOT NULL,
    "bucket" text,
    "key" text,
    "uploadid" text,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "uploads_pkey" PRIMARY KEY ("id")
) WITH (oids = false);


DROP TABLE IF EXISTS "datasets";
CREATE SEQUENCE datasets_dataset_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."datasets" (
    "dataset_id" integer DEFAULT nextval('datasets_dataset_id_seq') NOT NULL,
    "dataset_name" text,
    "view_name" text,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "datasets_pkey" PRIMARY KEY ("dataset_id")
) WITH (oids = false);


DROP TABLE IF EXISTS "systems";
CREATE TABLE "public"."systems" (
    "system_uuid" uuid NOT NULL,
    "vendor" text,
    "dnshostname" text,
    "username" text,
    "systemtype" text,
    "totalmem" bigint,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "systems_pkey" PRIMARY KEY ("system_uuid")
) WITH (oids = false);


DROP TABLE IF EXISTS "system_graphics";
CREATE SEQUENCE system_graphics_system_graphic_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;

CREATE TABLE "public"."system_graphics" (
    "system_graphic_id" integer DEFAULT nextval('system_graphics_system_graphic_id_seq') NOT NULL,
    "deviceid" text,
    "adaptercompatibility" text,
    "adapterdactype" text,
    "adapterram" integer,
    "availability" integer,
    "caption" text,
    "description" text,
    "driverdate" timestamptz,
    "driverversion" text,
    "pnpdeviceid" text,
    "name" text,
    "videoarch" integer,
    "memtype" integer,
    "videoprocessor" text,
    "bpp" integer,
    "hrez" integer,
    "vrez" integer,
    "num_colors" integer,
    "cols" integer,
    "rows" integer,
    "refresh" integer,
    "scanmode" integer,
    "videomodedesc" text,
    "created" timestamp DEFAULT timezone('utc')),
    CONSTRAINT "system_graphics_pkey" PRIMARY KEY ("system_graphic_id")
) WITH (oids = false);


DROP TABLE IF EXISTS "geography_columns";
CREATE TABLE "public"."geography_columns" (
    "f_table_catalog" name,
    "f_table_schema" name,
    "f_table_name" name,
    "f_geography_column" name,
    "coord_dimension" integer,
    "srid" integer,
    "type" text
) WITH (oids = false);

DROP TABLE IF EXISTS "geometry_columns";
CREATE TABLE "public"."geometry_columns" (
    "f_table_catalog" character varying(256),
    "f_table_schema" name,
    "f_table_name" name,
    "f_geometry_column" name,
    "coord_dimension" integer,
    "srid" integer,
    "type" character varying(30)
) WITH (oids = false);

DROP TABLE IF EXISTS "raster_columns";
CREATE TABLE "public"."raster_columns" (
    "r_table_catalog" name,
    "r_table_schema" name,
    "r_table_name" name,
    "r_raster_column" name,
    "srid" integer,
    "scale_x" double precision,
    "scale_y" double precision,
    "blocksize_x" integer,
    "blocksize_y" integer,
    "same_alignment" boolean,
    "regular_blocking" boolean,
    "num_bands" integer,
    "pixel_types" text[],
    "nodata_values" double precision[],
    "out_db" boolean[],
    "extent" geometry,
    "spatial_index" boolean
) WITH (oids = false);

DROP TABLE IF EXISTS "raster_overviews";
CREATE TABLE "public"."raster_overviews" (
    "o_table_catalog" name,
    "o_table_schema" name,
    "o_table_name" name,
    "o_raster_column" name,
    "r_table_catalog" name,
    "r_table_schema" name,
    "r_table_name" name,
    "r_raster_column" name,
    "overview_factor" integer
) WITH (oids = false);

-- 2018-01-24 19:34:12.973316+00