Skip to content

Commit

Permalink
Remove separate step for initializing TAP_SCHEMA database
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyMcCormick committed Jan 30, 2025
1 parent d0ede97 commit 7ddfe45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/test_mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,5 @@ jobs:
run: |
load-sql.sh mysql
# - name: Initialize TAP_SCHEMA database
# run: |
# # mysql -e "CREATE DATABASE TAP_SCHEMA;"
# felis init-tap-schema --engine-url ${FELIS_ENGINE_URL}

- name: Upload to TAP_SCHEMA database
- name: Load TAP_SCHEMA database
run: load-tap-schema.sh
6 changes: 1 addition & 5 deletions .github/workflows/test_postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,5 @@ jobs:
- name: Load SQL files
run: load-sql.sh postgresql

# - name: Initialize TAP_SCHEMA database
# run: |
# felis init-tap-schema --engine-url $FELIS_ENGINE_URL

- name: Upload to TAP_SCHEMA database
- name: Load TAP_SCHEMA
run: load-tap-schema.sh
6 changes: 1 addition & 5 deletions .github/workflows/test_sqlite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ jobs:
- name: Load SQL files
run: load-sql.sh sqlite

# - name: Initialize TAP_SCHEMA database
# run: |
# felis init-tap-schema --engine-url sqlite:///TAP_SCHEMA.db

- name: Load TAP_SCHEMA database
- name: Load TAP_SCHEMA
run: load-tap-schema.sh
32 changes: 9 additions & 23 deletions scripts/test/load-tap-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,34 @@ elif [[ "$protocol" == *"sqlite"* ]]; then
database="sqlite"
FELIS_ENGINE_URL="sqlite:///TAP_SCHEMA.db"
else
echo "Error: FELIS_ENGINE_URL protocol must contain one of 'mysql', 'postgresql' or 'sqlite'."
echo "Error: FELIS_ENGINE_URL protocol must be one of 'mysql', 'postgresql' or 'sqlite'"
exit 1
fi

echo "Detected database type: $database"

# Initialize a variable to track if any command fails
error_occurred=0

for yaml_file in yml/*.yaml; do
filename=$(basename "$yaml_file")
echo "Uploading to TAP_SCHEMA from $yaml_file..."
echo "Loading TAP_SCHEMA from $yaml_file..."
felis --log-level ERROR init-tap-schema --engine-url ${FELIS_ENGINE_URL}
felis --log-level ERROR load-tap-schema --engine-url ${FELIS_ENGINE_URL} "$yaml_file"
# Check if the felis command was successful
if [ $? -ne 0 ]; then
echo "Error: Failed to create SQL from $yaml_file"
error_occurred=1
else
echo "Done uploading to TAP_SCHEMA from $yaml_file"
fi
# if [[ "$database" == "mysql" ]]; then
# mysql -DTAP_SCHEMA -e "
# DELETE FROM \`columns\`;
# DELETE FROM \`key_columns\`;
# DELETE FROM \`keys\`;
# DELETE FROM \`schemas\`;
# DELETE FROM \`tables\`;
# " &> /dev/null
# if [[ "$database" == "postgresql" ]]; then
# psql -q -c "TRUNCATE TABLE columns, key_columns, keys, schemas, tables;" &> /dev/null
#elif [[ "$database" == "sqlite" ]]; then
# sqlite3 TAP_SCHEMA.db "DELETE FROM columns;
# DELETE FROM key_columns;
# DELETE FROM keys;
# DELETE FROM schemas;
# DELETE FROM tables;
# " &> /dev/null
#fi
if [[ "database" == "mysql" ]]; then
# Drop the TAP_SCHEMA database or schema
if [[ "$database" == "mysql" ]]; then
echo "Dropping TAP_SCHEMA mysql database..."
mysql -e "DROP DATABASE TAP_SCHEMA;"
elif [[ "$database" == "postgresql" ]]; then
echo "Dropping TAP_SCHEMA postgresql schema..."
psql -c "DROP SCHEMA \"TAP_SCHEMA\" CASCADE;"
elif [[ "$database" == "sqlite" ]]; then
echo "Dropping TAP_SCHEMA sqlite database..."
rm TAP_SCHEMA.db
fi
done
Expand Down

0 comments on commit 7ddfe45

Please sign in to comment.