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

int main ()
{
    psDB            *dbh;

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

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

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

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS summitImfile");
    summitImfileCreateTable(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 pzDoneExp");
    pzDoneExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS pzDoneImfile");
    pzDoneImfileCreateTable(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 rawExp");
    rawExpCreateTable(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 p2ProcessedExp");
    p2ProcessedExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2Mask");
    p2MaskCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p2ProcessedImfile");
    p2ProcessedImfileCreateTable(dbh);

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

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p3ProcessedExp");
    p3ProcessedExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p3Mask");
    p3MaskCreateTable(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 detProcessedExp");
    detProcessedExpCreateTable(dbh);

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

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detNormalizedStatImfile");
    detNormalizedStatImfileCreateTable(dbh);

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

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detNormalizedExp");
    detNormalizedExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidImfile");
    detResidImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detResidExp");
    detResidExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS detRunSummary");
    detRunSummaryCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aRun");
    p4aRunCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aInputExp");
    p4aInputExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4aScfile");
    p4aScfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bRun");
    p4bRunCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bInputScfile");
    p4bInputScfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4bDiffScfile");
    p4bDiffScfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cRun");
    p4cRunCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4cInputExp");
    p4cInputExpCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4MagicMaskImfile");
    p4MagicMaskImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCell");
    skyCellCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS skyCellMap");
    skyCellMapCreateTable(dbh);

    psDBCleanup(dbh);

    exit(EXIT_SUCCESS);
}
