Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN TRANSACTION ;
- ALTER TABLE history.hosts ADD COLUMN host_health numeric;
- ALTER TABLE hosts ADD COLUMN host_health numeric not null default 0;
- ALTER TABLE history.hosts ADD COLUMN host_status text;
- ALTER TABLE hosts ADD COLUMN host_status text not null default 'unknown';
- DROP FUNCTION history_hosts() CASCADE ;
- CREATE FUNCTION history_hosts() RETURNS trigger
- AS $$
- DECLARE
- history_hosts RECORD;
- BEGIN
- SELECT INTO history_hosts * FROM hosts WHERE host_uuid = new.host_uuid;
- INSERT INTO history.hosts
- (host_uuid,
- host_name,
- host_type,
- host_key,
- host_ipmi,
- host_health,
- host_status,
- modified_date)
- VALUES
- (history_hosts.host_uuid,
- history_hosts.host_name,
- history_hosts.host_type,
- history_hosts.host_key,
- history_hosts.host_ipmi,
- history_hosts.host_health,
- history_hosts.host_status,
- history_hosts.modified_date);
- RETURN NULL;
- END;
- $$
- LANGUAGE plpgsql;
- ALTER FUNCTION history_hosts() OWNER TO admin;
- CREATE TRIGGER trigger_hosts
- AFTER INSERT OR UPDATE ON hosts
- FOR EACH ROW EXECUTE PROCEDURE history_hosts();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement