|
package dvomigrations
import (
"database/sql"
"github.com/RedHatInsights/insights-results-aggregator/migration"
"github.com/RedHatInsights/insights-results-aggregator/types"
)
var mig0001CreateDVOReport = migration . Migration {
StepUp : func ( tx * sql . Tx , _ types . DBDriver ) error {
_ , err := tx . Exec ( `
CREATE TABLE dvo.dvo_report (
org_id INTEGER NOT NULL,
cluster_id VARCHAR NOT NULL,
namespace_id VARCHAR NOT NULL,
namespace_name VARCHAR,
report TEXT,
recommendations INTEGER NOT NULL,
objects INTEGER NOT NULL,
reported_at TIMESTAMP,
last_checked_at TIMESTAMP,
PRIMARY KEY(org_id, cluster_id, namespace_id)
);
` )
if err != nil {
return err
}
_ , err = tx . Exec ( `
COMMENT ON TABLE dvo.dvo_report IS 'This table is used as a cache for DVO reports. Only the latest report for a given cluster is stored.';
COMMENT ON COLUMN dvo.dvo_report.org_id IS 'organization ID';
COMMENT ON COLUMN dvo.dvo_report.cluster_id IS 'cluster UUID';
COMMENT ON COLUMN dvo.dvo_report.namespace_id IS 'namespace UUID (always set)';
COMMENT ON COLUMN dvo.dvo_report.namespace_name IS 'namespace name (might be null - not set)';
COMMENT ON COLUMN dvo.dvo_report.report IS 'report structure stored in JSON format';
COMMENT ON COLUMN dvo.dvo_report.recommendations IS 'number of recommendations stored in report';
COMMENT ON COLUMN dvo.dvo_report.objects IS 'number of objects stored in report';
COMMENT ON COLUMN dvo.dvo_report.reported_at IS 'timestamp, same meaning as in report table';
COMMENT ON COLUMN dvo.dvo_report.last_checked_at IS 'timestamp, same meaning as in report table';
` )
return err
} ,
StepDown : func ( tx * sql . Tx , _ types . DBDriver ) error {
_ , err := tx . Exec ( `DROP TABLE dvo.dvo_report;` )
return err
} ,
}
|