/* Detections. PS1-specific detection attributes. */
drop table if exists det_rawattr_v2;
create table det_rawattr_v2(
    det_id bigint                               comment 'Source det_id',

    psf_chi2 float,
    psf_dof int,
    cr_sig float,
    ext_sig float,
    psf_major float,
    psf_minor float,
    psf_theta float,
    psf_quality float,
    psf_npix int,
    moments_xx float,
    moments_xy float,
    moments_yy float,
    n_pos int,
    f_pos float,
    ratio_bad float,
    ratio_mask float,
    ratio_all float,
    flags int,
    ipp_idet int,
    psf_inst_flux float,
    psf_inst_flux_sig float,
    ap_mag float,
    ap_mag_raw float,
    ap_mag_radius float,
    ap_flux float,
    ap_flux_sig float,
    peak_flux_as_mag float,
    cal_psf_mag float,
    cal_psf_mag_sig float,
    sky float,
    sky_sigma float,
    psf_qf_perfect float,
    moments_r1 float,
    moments_rh float,
    kron_flux float,
    kron_flux_err float,
    kron_flux_inner float,
    kron_flux_outer float,
    diff_r_p float,
    diff_sn_p float,
    diff_r_m float,
    diff_sn_m float,
    flags2 int,
    n_frames int,

    FOREIGN KEY (det_id) REFERENCES detections(det_id) ON DELETE CASCADE
) type=InnoDB;
