91 lines
5.5 KiB
Plaintext
Executable File
91 lines
5.5 KiB
Plaintext
Executable File
-- $Id$
|
|
-- $HeadURL$
|
|
-- $Author$
|
|
|
|
-------------------------------------------------------------------------
|
|
-- INFO: AES updates (enum, explosion single central table, recorded table and view)
|
|
-- PROJECT: Ahtc
|
|
-- DATE: 2021-03-12
|
|
-- VERSION: 1.03
|
|
-------------------------------------------------------------------------
|
|
|
|
-- GLOBAL: NONE;
|
|
BEGIN;
|
|
COMMIT;
|
|
|
|
-- EXERCISE: ALL;
|
|
BEGIN;
|
|
|
|
-- enum
|
|
ALTER TABLE IF EXISTS aes_fuse_type DROP CONSTRAINT IF EXISTS PK_aes_fuse_type_id CASCADE;
|
|
DROP TABLE IF EXISTS aes_fuse_type CASCADE;
|
|
CREATE TABLE IF NOT EXISTS aes_fuse_type (
|
|
id integer,
|
|
name text
|
|
);
|
|
COMMENT ON TABLE aes_fuse_type IS 'static data (<b>not</b> project specific) generate from enum';
|
|
ALTER TABLE IF EXISTS aes_fuse_type ADD CONSTRAINT PK_aes_fuse_type_id PRIMARY KEY (id);
|
|
INSERT INTO aes_fuse_type (id, name) VALUES (0, 'FtProximity');
|
|
INSERT INTO aes_fuse_type (id, name) VALUES (1, 'FtImpact');
|
|
INSERT INTO aes_fuse_type (id, name) VALUES (2, 'FtDelay');
|
|
|
|
-- table aes_explosion_single_central
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central DROP CONSTRAINT IF EXISTS PK_aes_explosion_single_central_id CASCADE;
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central DROP CONSTRAINT IF EXISTS FK_aes_explosion_single_central_explosion_single_id_aes_explosi CASCADE;
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central DROP CONSTRAINT IF EXISTS FK_aes_explosion_single_central_fuse_type_id_aes_fuse_type_id CASCADE;
|
|
DROP TABLE IF EXISTS aes_explosion_single_central CASCADE;
|
|
CREATE SEQUENCE IF NOT EXISTS aes_explosion_single_central_id_seq INCREMENT 1 START 1 MINVALUE 1;
|
|
CREATE TABLE IF NOT EXISTS aes_explosion_single_central (
|
|
id integer DEFAULT nextval(( 'aes_explosion_single_central_id_seq'::text)::regclass),
|
|
explosion_single_id integer,
|
|
angle double precision,
|
|
fuse_type_id integer
|
|
);
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central ADD CONSTRAINT PK_aes_explosion_single_central_id PRIMARY KEY (id);
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central ADD CONSTRAINT FK_aes_explosion_single_central_explosion_single_id_aes_explosi FOREIGN KEY (explosion_single_id) REFERENCES aes_explosion_single (id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
ALTER TABLE IF EXISTS aes_explosion_single_central ADD CONSTRAINT FK_aes_explosion_single_central_fuse_type_id_aes_fuse_type_id FOREIGN KEY (fuse_type_id) REFERENCES aes_fuse_type (id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- recorded table rec_explosion_single_central
|
|
ALTER TABLE IF EXISTS rec_explosion_single_central DROP CONSTRAINT IF EXISTS PK_rec_explosion_single_central_rec_id CASCADE;
|
|
ALTER TABLE IF EXISTS rec_explosion_single_central DROP CONSTRAINT IF EXISTS IDX_rec_explosion_single_central_sample_time CASCADE;
|
|
DROP TABLE IF EXISTS rec_explosion_single_central CASCADE;
|
|
CREATE SEQUENCE IF NOT EXISTS rec_explosion_single_central_rec_id_seq INCREMENT 1 START 1 MINVALUE 1;
|
|
CREATE TABLE IF NOT EXISTS rec_explosion_single_central (
|
|
id integer,
|
|
name text,
|
|
is_deleted boolean,
|
|
is_used boolean,
|
|
sample_time bigint,
|
|
charge_type_id integer,
|
|
effect_duration integer,
|
|
effect_start bigint,
|
|
effect_state_id integer,
|
|
party_id integer,
|
|
participant_id integer,
|
|
effect_marking_in_ta boolean,
|
|
external_id bigint,
|
|
impact_position_lon double precision,
|
|
impact_position_lat double precision,
|
|
fire_request_time bigint,
|
|
altitude integer,
|
|
purpose text,
|
|
angle double precision,
|
|
fuse_type integer,
|
|
rec_id bigint DEFAULT nextval(( 'rec_explosion_single_central_rec_id_seq'::text)::regclass),
|
|
dds_is_alive boolean DEFAULT true,
|
|
insert_time bigint DEFAULT (extract(epoch from now()) * 1000)
|
|
);
|
|
COMMENT ON TABLE rec_explosion_single_central IS 'recorded data for topic ExplosionSingleCentral';
|
|
ALTER TABLE IF EXISTS rec_explosion_single_central ADD CONSTRAINT PK_rec_explosion_single_central_rec_id PRIMARY KEY (rec_id);
|
|
CREATE INDEX IDX_rec_explosion_single_central_sample_time ON rec_explosion_single_central (sample_time);
|
|
|
|
-- view aes_explosion_single_central_view
|
|
DROP VIEW IF EXISTS aes_explosion_single_central_view;
|
|
CREATE OR REPLACE VIEW aes_explosion_single_central_view AS SELECT aes_entity.id AS id, aes_entity.charge_type_id AS charge_type_id, aes_entity.effect_state_id AS effect_state_id, aes_entity.party_id AS party_id, aes_entity.participant_id AS participant_id, aes_entity.effect_duration AS effect_duration, aes_entity.effect_start AS effect_start, aes_entity.name AS name, aes_entity.effect_marking_in_ta AS effect_marking_in_ta, aes_entity.external_id AS external_id, aes_explosion.entity_id AS entity_id, aes_explosion.impact_position_x AS impact_position_x, aes_explosion.impact_position_y AS impact_position_y, aes_explosion.rotation_angle AS rotation_angle, aes_explosion.fire_purpose AS fire_purpose, aes_explosion.fire_request_time AS fire_request_time, aes_explosion.altitude AS altitude, aes_explosion_single.explosion_id AS explosion_id, aes_explosion_single_central.explosion_single_id AS explosion_single_id, aes_explosion_single_central.angle AS angle, aes_explosion_single_central.fuse_type_id AS fuse_type_id, aes_explosion_single_central.id AS aes_explosion_single_central_id
|
|
FROM aes_explosion_single_central, aes_entity, aes_explosion, aes_explosion_single
|
|
WHERE aes_entity.id = aes_explosion.entity_id AND
|
|
aes_explosion.id = aes_explosion_single.explosion_id AND
|
|
aes_explosion_single.id = aes_explosion_single_central.explosion_single_id;
|
|
|
|
COMMIT;
|