Skip to content
Snippets Groups Projects
Commit d93482b4 authored by Rafael De Lima Prado's avatar Rafael De Lima Prado
Browse files

database: Remove these files, they are no more necessary

parent 748c1a1d
No related branches found
No related tags found
No related merge requests found
CREATE LANGUAGE plpgsql;
-- copy inventory data directly from the production database
CREATE OR REPLACE FUNCTION copy_inventory_from_seed() returns void as $$
BEGIN
-- inserting rows from production staging area into sa_inventory
INSERT INTO proinfo_inventory
(contact_date, project, inep, macaddr, os_type, os_distro,
os_kernel, processor, memory, disk1_model, disk1_size,
disk1_used, disk2_model, disk2_size, disk2_used)
(SELECT
*
FROM
dblink('dbname=db
host=host
user=user
password=passwd',
'SELECT
sa_data,
sa_projeto,
sa_inep,
sa_mac,
sa_so_nome,
sa_so_distribuicao,
sa_so_kernel,
sa_processador,
sa_memoria,
sa_disco1_modelo,
sa_disco1_capacidade,
sa_disco1_usado,
sa_disco2_modelo,
sa_disco2_capacidade,
sa_disco2_usado
FROM mectb00_staging_area'
)
AS (
contact_date date,
project integer,
inep varchar(18),
macaddr varchar(18),
os_type text,
os_distro text,
os_kernel text,
processor text,
memory integer,
disk1_model text,
disk1_size integer,
disk1_used integer,
disk2_model text,
disk2_size integer,
disk2_used integer
));
END;
$$ language plpgsql;
-- copy net usage data directly from the production database
CREATE OR REPLACE FUNCTION copy_net_from_seed(date_to_load DATE) returns void as $$
BEGIN
INSERT INTO proinfo_net_usage
(contact_date, inep, macaddr, collect_time, down_kbits, down_packages, up_kbits, up_packages)
(SELECT
*
FROM
dblink('dbname=db
host=host
user=user
password=passwd',
'SELECT
net_data,
net_inep,
net_mac,
net_hora,
net_bytes_in::integer,
net_pacotes_in,
net_bytes_out::integer,
net_pacotes_out
FROM mectb00_net_staging_area
WHERE
net_data = ''' || date_to_load ||'''
AND net_bytes_in <> 0
AND net_pacotes_in <> 0
AND net_bytes_out <> 0
AND net_pacotes_in <> 0'
)
AS (
contact_date DATE,
inep VARCHAR(18),
macaddr VARCHAR(18),
collect_time TIME WITHOUT TIME ZONE,
down_kbits BIGINT,
down_packages INTEGER,
up_kbits BIGINT,
up_packages INTEGER
));
END;
$$ language plpgsql;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment