/*
   This file is part of Challenger
   Copyright (C) 2023 Taler Systems SA

   Challenger is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
   Foundation; either version 3, or (at your option) any later version.

   Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along with
   Challenger; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file src/challengerdb/create_tables.c
 * @brief Implementation of the create_tables function for Postgres
 * @author Christian Grothoff
 */
#include "platform.h"
#include <taler/taler_error_codes.h>
#include <taler/taler_dbevents.h>
#include <taler/taler_pq_lib.h>
#include "challenger-database/create_tables.h"
#include "pg_helper.h"


enum GNUNET_GenericReturnValue
CHALLENGERDB_create_tables (struct CHALLENGERDB_PostgresContext *pc)
{
  if (GNUNET_SYSERR ==
      GNUNET_PQ_load_versioning (pc->conn))
  {
    GNUNET_break (0);
    return GNUNET_SYSERR;
  }
  if (GNUNET_OK !=
      GNUNET_PQ_run_sql (pc->conn,
                         "challenger-"))
  {
    GNUNET_break (0);
    return GNUNET_SYSERR;
  }
  return GNUNET_PQ_exec_sql (pc->conn,
                             "procedures");
}
