--
--

CREATE TABLE nephtys_data (
    id serial primary key,
    calibrated_filename character varying(255),
    telescop character varying(80),
    instrume character varying(80),
    targname character varying(80),
    tdateobs date,
    ttimeobs time without time zone,
    datetime timestamp without time zone,
    texptime double precision,
    obstype character varying(80),
    obsmode character varying(80),
    photmode character varying(80),
    detector character varying(80),
    opt_elem character varying(80),
    filter character varying(80),
    orientat double precision,
    sunangle double precision,
    moonangl double precision,
    sun_alt double precision,
    bandwid double precision,
    specres double precision,
    centrwv double precision,
    minwave double precision,
    maxwave double precision,
    last_update timestamp without time zone,
    bunit character varying(80),
    proposid integer,
    pr_inv_l character varying(80),
    propttl1 character varying(255),
    origin character varying(80),
    ra_targ double precision,
    dec_targ double precision,
    platesc double precision,
    tardescr character varying(80),
    date timestamp without time zone,
    processed_filename character varying(255),
    cylindric_filename character varying(255),
    calibrated_preview character varying(255),
    processed_preview character varying(255),
    cylindric_preview character varying(255),
    processed_pdf character varying(255),
    cylindric_pdf character varying(255),
    cal_ver character varying(80),
    rootname character varying(80),
    campaign character varying(80),
    subelat double precision,
    subslat double precision,
    subelon double precision,
    subslon double precision,
    dists double precision,
    diste double precision,
    rap double precision,
    np_pos double precision,
    phase double precision,
    skr_n double precision,
    skr_s double precision,
    hemis1 character varying(80),
    hemis2 character varying(80),
    spectrum_filename character varying(255),
    spectrum_preview character varying(255),
    spectrum_pdf character varying(255),
    polar_n_filename character varying(255),
    polar_s_filename character varying(255),
    polar_n_preview character varying(255),
    polar_s_preview character varying(255),
    polar_n_pdf character varying(255),
    polar_s_pdf character varying(255),
    modified_at timestamp without time zone,
    date_processed timestamp without time zone,
    lon_io double precision,
    lt_io double precision,
    lon_eur double precision,
    lt_eur double precision,
    lon_gan double precision,
    lt_gan double precision,
    lon_cal double precision,
    lt_cal double precision,
    lt_mim double precision,
    lt_enc double precision,
    lt_the double precision,
    lt_dio double precision,
    lt_rhe double precision,
    lt_tit double precision,
    rj_gal double precision,
    lat_gal double precision,
    lt_gal double precision,
    rs_cas double precision,
    lat_cas double precision,
    lt_cas double precision,
    spectral_step double precision,
    publisher_original    character varying,
    service_title_original    character varying
);




REVOKE ALL ON TABLE nephtys_data FROM PUBLIC;
GRANT ALL ON TABLE nephtys_data TO gavoadmin;
GRANT SELECT ON TABLE nephtys_data TO gavo;


DROP TRIGGER update_datetime ON nephtys_data;
CREATE TRIGGER update_datetime
BEFORE UPDATE OR INSERT ON nephtys_data
   FOR EACH ROW EXECUTE PROCEDURE update_datetime();


