1 DROP VIEW planet_scans;
2 DROP VIEW structure_scans;
4 CREATE TABLE planet_scans (
5 id integer PRIMARY KEY REFERENCES scans(id),
6 planet integer NOT NULL REFERENCES planets(id),
9 crystal bigint NOT NULL,
10 eonium bigint NOT NULL,
11 hidden bigint NOT NULL,
12 metal_roids integer NOT NULL,
13 crystal_roids integer NOT NULL,
14 eonium_roids integer NOT NULL,
15 agents integer NOT NULL,
16 guards integer NOT NULL,
23 CREATE TABLE structure_scans (
24 id integer PRIMARY KEY REFERENCES scans(id),
25 planet integer NOT NULL REFERENCES planets(id),
26 tick integer NOT NULL,
27 light_fac integer NOT NULL,
28 medium_fac integer NOT NULL,
29 heavy_fac integer NOT NULL,
30 amps integer NOT NULL,
31 distorters integer NOT NULL,
32 metal_ref integer NOT NULL,
33 crystal_ref integer NOT NULL,
34 eonium_ref integer NOT NULL,
35 reslabs integer NOT NULL,
36 fincents integer NOT NULL,
37 seccents integer NOT NULL,
38 total integer NOT NULL
41 CREATE TABLE tech_scans (
42 id integer PRIMARY KEY REFERENCES scans(id),
43 planet integer NOT NULL REFERENCES planets(id),
44 tick integer NOT NULL,
45 travel integer NOT NULL,
46 infra integer NOT NULL,
47 hulls integer NOT NULL,
48 waves integer NOT NULL,
49 extraction integer NOT NULL,
50 covert integer NOT NULL,
51 mining integer NOT NULL
54 CREATE OR REPLACE VIEW current_planet_scans AS
55 SELECT DISTINCT ON (planet) ps.*
57 ORDER BY planet, tick DESC, id DESC;
59 CREATE OR REPLACE VIEW current_structure_scans AS
60 SELECT DISTINCT ON (planet) ss.*
61 FROM structure_scans ss
62 ORDER BY planet, tick DESC, id DESC;
64 CREATE OR REPLACE VIEW current_tech_scans AS
65 SELECT DISTINCT ON (planet) ts.*
67 ORDER BY planet, tick DESC, id DESC;
69 CREATE INDEX planet_scans_planet_index ON planet_scans(planet,tick);
70 CREATE INDEX structure_scans_planet_index ON structure_scans(planet,tick);
71 CREATE INDEX tech_scans_planet_index ON tech_scans(planet,tick);
73 DROP TABLE planet_data;
74 DROP TABLE planet_data_types;