CREATE TABLE IF NOT EXISTS osh.scans(
    scan_id SERIAL,
    offering_id VARCHAR(100),
    event_id VARCHAR(100) NOT NULL,
    is_managed_service BOOLEAN NOT NULL,
    component_list VARCHAR(100),
    datetime TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
    owner VARCHAR(50) NOT NULL,
    results SERIAL,
    status VARCHAR (50) CONSTRAINT valid_status CHECK(status in ('PENDING', 'DELETED', 'COMPLETED', 'IN PROGRESS')),
    last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW() AT TIME ZONE 'utc') NOT NULL,
    PRIMARY KEY(scan_id),
    FOREIGN KEY (offering_id) REFERENCES osh.offerings(offering_id),
    FOREIGN KEY (results) REFERENCES osh.results(results_id)
);

INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(1,'ansible-automation-platform','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',1,'PENDING');
INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(2,'ansible-automation-platform','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',1,'IN PROGRESS');
INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(3,'ansible-automation-platform','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',1,'COMPLETED');
INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(4,'eclipse-vertx','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',2,'PENDING');
INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(5,'eclipse-vertx','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',2,'IN PROGRESS');
INSERT INTO osh.scans (scan_id,offering_id,event_id,is_managed_service,component_list,datetime,owner,results,status)
  VALUES(6,'eclipse-vertx','event-id-1',true,'publisher','2023-06-22 16:04:04.816453','RedHat',2,'COMPLETED');
