#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 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 p4Run");
    p4RunCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4InputImfile");
    p4InputImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4WarpedImfile");
    p4WarpedImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4StackedImfile");
    p4StackedImfileCreateTable(dbh);

    p_psDBRunQuery(dbh, "DROP TABLE IF EXISTS p4DiffImfile");
    p4DiffImfileCreateTable(dbh);

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

    psDBCleanup(dbh);

    exit(EXIT_SUCCESS);
}
