#include <pslib.h>
#include <ippdb.h>
#include <stdlib.h>

int main ()
{
    psDB            *dbh;

    dbh = psDBInit("localhost", "test", NULL, "test");
    if (!dbh) {
        exit(EXIT_FAILURE);
    }

    // remove the table if it already exists
    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS weather");
    weatherCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyp_transparency");
    skyp_transparencyCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyp_absorption");
    skyp_absorptionCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyp_emission");
    skyp_emissionCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS dimm");
    dimmCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyp_ir");
    skyp_irCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS dome");
    domeCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS telescope");
    telescopeCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitExp");
    summitExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS pzPendingExp");
    pzPendingExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS pzPendingImfile");
    pzPendingImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS newExp");
    newExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS newImfile");
    newImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS rawDetrendExp");
    rawDetrendExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS rawScienceExp");
    rawScienceExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS rawImfile");
    rawImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p1PendingExp");
    p1PendingExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2PendingExp");
    p2PendingExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2PendingImfile");
    p2PendingImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2DoneExp");
    p2DoneExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2DoneImfile");
    p2DoneImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p3PendingExp");
    p3PendingExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detRun");
    detRunCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detInputExp");
    detInputExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detProcessedImfile");
    detProcessedImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detStackedImfile");
    detStackedImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detNormalizedImfile");
    detNormalizedImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detMasterFrame");
    detMasterFrameCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detMasterImfile");
    detMasterImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidImfileAnalysis");
    detResidImfileAnalysisCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidExpAnalysis");
    detResidExpAnalysisCreateTable(dbh);

    psDBCleanup(dbh);

    exit(EXIT_SUCCESS);
}
