#!/bin/bash
# ===========================================================================
# Copyright (c) 2021,2023 Eclipse Foundation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#    Christopher Guindon (Eclipse Foundation)
# ==========================================================================

# Import helper functions for this script
if [[ ! -f "../_shared/bash/import-helpers.sh" ]]
then
  echo 'Exiting... This script is not meant to be exectuted directly. See the Makefile of the project for more info.'
  exit 0
fi
source ../_shared/bash/import-helpers.sh

# Database
MARIADB_CONTAINER_NAME=$(docker-compose ps -q mariadb)

# Ensure that the sql folder exist
mkdir -p sql

# import bugs database with no-data
DATABASE_FILE="bugs-no-data.sql.gz"
DATABASE_NAME=bugs
scp api-vm1:webdev/sql/$DATABASE_FILE sql/
import_db_docker

# import eclipsefoundation database with no-data
DATABASE_FILE="eclipsefoundation-no-data.sql.gz"
DATABASE_NAME=eclipsefoundation
scp api-vm1:webdev/sql/$DATABASE_FILE sql/
import_db_docker

# import eclipse database with no-data
DATABASE_FILE="eclipse-no-data.sql.gz"
DATABASE_NAME=eclipse
scp api-vm1:webdev/sql/$DATABASE_FILE sql/
import_db_docker

# import dashboard database with no-data
DATABASE_FILE="dashboard-no-data.sql.gz"
DATABASE_NAME=dashboard
scp api-vm1:webdev/sql/$DATABASE_FILE sql/
import_db_docker

# import ipzilla database with no-data
DATABASE_FILE="ipzilla-no-data.sql.gz"
DATABASE_NAME=ipzilla
scp api-vm1:webdev/sql/$DATABASE_FILE sql/
import_db_docker
