Skip to content

Commit

Permalink
Move DROP_SOURCE_DB process to module file
Browse files Browse the repository at this point in the history
  • Loading branch information
nwillhoft committed Feb 6, 2025
1 parent 323fcf9 commit 4bcb3db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
34 changes: 34 additions & 0 deletions nextflow/modules/db_cleanup/drop_source_db.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// See the NOTICE file distributed with this work for additional information
// regarding copyright ownership.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

nextflow.enable.dsl=2

process DROP_SOURCE_DB {

input:
tuple val(job_id), val(db_name)

script:
println "Dropping source database: ${db_name}"

"""
echo "Attempting to drop database ${db_name} if it exists..."
mysql -h $params.target_host -P $params.target_port -u $params.dba_user -p$params.dba_pwd -e "DROP DATABASE IF EXISTS ${db_name};"
echo "Drop operation complete."
"""

}
18 changes: 1 addition & 17 deletions nextflow/workflows/db_cleanup/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include { MONITOR_DB_COPY } from '../../modules/db_cleanup/monitor_db_copy.nf'
include { GENERATE_SQL } from '../../modules/db_cleanup/generate_sql.nf'
include { COMPRESS_FILE } from '../../modules/db_cleanup/compress_file.nf'
include { CLEANUP_TMP_DB } from '../../modules/db_cleanup/cleanup_tmp_db.nf'
include { DROP_SOURCE_DB } from '../../modules/db_cleanup/drop_source_db.nf'

// nf-schema-related modules
include { validateParameters; paramsSummaryLog; samplesheetToList } from 'plugin/nf-schema'
Expand Down Expand Up @@ -95,23 +96,6 @@ process TAR_COMPRESSED_SQL {
"""
}

process DROP_SOURCE_DB {

input:
tuple val(job_id), val(db_name)

script:
"""
echo "Attempting to drop database ${db_name} if it exists..."
mysql -h $params.target_host -P $params.target_port -u $params.dba_user -p$params.dba_pwd -e "DROP DATABASE IF EXISTS ${db_name};"
echo "Drop operation complete."
"""

}


workflow {

main:
Expand Down

0 comments on commit 4bcb3db

Please sign in to comment.