#!/bin/bash
set -e
set -o pipefail
set -u

#   BAREOS® - Backup Archiving REcovery Open Sourced
#
#   Copyright (C) 2026-2026 Bareos GmbH & Co. KG
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program 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
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program. If not, see <https://www.gnu.org/licenses/>.

# Prepare a schema-2250 catalog with a basefiles row for the upgrade test.
TestName="$(basename "$(pwd)")"
export TestName

#shellcheck source=../../environment.in
. ./environment

#shellcheck source=../../scripts/functions
. "${BAREOS_SCRIPTS_DIR}"/functions
"${BAREOS_SCRIPTS_DIR}"/cleanup

export SQL_DDL_DIR="${current_test_directory}/bareos_25_db_2250_ddl"
"${BAREOS_SCRIPTS_DIR}"/setup
unset SQL_DDL_DIR

"${POSTGRES_BIN_PATH}/psql" -v ON_ERROR_STOP=1 "${db_name}" <<'SQL'
INSERT INTO public.basefiles (JobId, FileId, FileIndex, BaseJobId)
VALUES (1, 1, 1, 1);
SQL
