Skip to content
Snippets Groups Projects
Commit fd92c46a authored by Eric Cano's avatar Eric Cano
Browse files

Added creation of the DB schemas in cmake.

This required fixing the SQL creation script.
parent 976c116e
Branches
Tags
No related merge requests found
......@@ -25,4 +25,18 @@ cmake_minimum_required (VERSION 2.6)
add_subdirectory (cnv)
if (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (ora)
endif (${COMPILE_SERVER} STREQUAL "1")
\ No newline at end of file
endif (${COMPILE_SERVER} STREQUAL "1")
# Generate the SQL schema creation script for the stager
FILE(READ stager_oracle_create.list STAGER_SQL_LIST)
STRING(REPLACE "\n" ";" STAGER_SQL_LIST "${STAGER_SQL_LIST}")
STRING(REPLACE " " "" STAGER_SQL_LIST "${STAGER_SQL_LIST}")
add_custom_target(stager_oracle_create.sql ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/makeSqlScripts.sh stager ${CASTOR_DB_VERSION} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS oracleSchema.sql oracleHeader.sql ${STAGER_SQL_LIST}
COMMENT Creating stager_oracle_create.sql
)
CastorInstallSQL(stager_oracle_create.sql)
CastorInstallSQLFromSource(drop_oracle_schema.sql)
CastorInstallConfigNoRename(SQLSchemaTests.conf)
CastorInstallScript(castor-SQLSchemaTests)
......@@ -72,3 +72,13 @@ target_link_libraries (vdqmDBInit castorcnvs castorcommon castorvmgr
castorcommonora castorvdqmora)
install (TARGETS vdqmDBInit DESTINATION ${CASTOR_DEST_BIN_DIR})
CastorInstallExeManPage (vdqmDBInit)
################################################################################
# Rules to build and install the VDQM oracle SQL schema
################################################################################
add_custom_target(vdqm_oracle_create.sql ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/makeSqlScripts.sh vdqm ${CASTOR_DB_VERSION} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS oracleSchema.sql oracleTrailer.sql
COMMENT Creating vdqm_oracle_create.sql
)
CastorInstallSQL(vdqm_oracle_create.sql)
......@@ -53,6 +53,7 @@ string(REGEX REPLACE "\\..*" "" MAJOR_CASTOR_VERSION_TOP ${MAJOR_CASTOR_VERSION}
string(REGEX REPLACE ".*\\." "" MAJOR_CASTOR_VERSION_BOTTOM ${MAJOR_CASTOR_VERSION})
string(REGEX REPLACE "\\..*" "" MINOR_CASTOR_VERSION_TOP ${MINOR_CASTOR_VERSION})
string(REGEX REPLACE ".*\\." "" MINOR_CASTOR_VERSION_BOTTOM ${MINOR_CASTOR_VERSION})
message(STATUS "Generated derived versions: CASTOR_VERSION: ${CASTOR_VERSION} CASTOR_RELEASE: ${CASTOR_RELEASE}")
set(CASTOR_DB_VERSION "${MAJOR_CASTOR_VERSION_TOP}_${MAJOR_CASTOR_VERSION_BOTTOM}_${MINOR_CASTOR_VERSION_TOP}_${MINOR_CASTOR_VERSION_BOTTOM}")
message(STATUS "Generated derived versions: CASTOR_VERSION: ${CASTOR_VERSION} CASTOR_RELEASE: ${CASTOR_RELEASE} CASTOR_DB_VERSION: ${CASTOR_DB_VERSION}")
message(STATUS "MAJOR_CASTOR_VERSION_TOP=${MAJOR_CASTOR_VERSION_TOP} MAJOR_CASTOR_VERSION_BOTTOM=${MAJOR_CASTOR_VERSION_BOTTOM}")
message(STATUS "MINOR_CASTOR_VERSION_TOP=${MINOR_CASTOR_VERSION_TOP} MINOR_CASTOR_VERSION_BOTTOM=${MINOR_CASTOR_VERSION_BOTTOM}")
......@@ -291,3 +291,13 @@ if (${COMPILE_SERVER} STREQUAL "1")
CastorInstallSysconfigExample(nsd.secure)
CastorInstallLogrotate(castor-ns-server)
endif (${COMPILE_SERVER} STREQUAL "1")
################################################################################
# Rules to build and install the ns oracle SQL schema
################################################################################
add_custom_target(cns_oracle_create.sql ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/makeSqlScripts.sh cns ${CASTOR_DB_VERSION} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS oracleSchema.sql oracleTrailer.sql
COMMENT Creating cns_oracle_create.sql
)
CastorInstallSQL(cns_oracle_create.sql)
......@@ -18,24 +18,30 @@ fi
# Construct the database schema name in uppercase
schemaname=`echo $1 | tr '[a-z]' '[A-Z]'`
if [ $# == 3 ]; then
rm -rf $1_oracle_create.sql*
if [ $# == 4 ]; then
destdir=`readlink -f $4`
destdir=${destdir}/
else
destdir=""
fi
rm -rf ${destdir}$1_oracle_create.sql*
# force the SQL client to exit on errors
/bin/cat > $1_oracle_create.sql <<EOF
# force the SQL client to exit on errors
/bin/cat > ${destdir}$1_oracle_create.sql <<EOF
/* Stop on errors */
WHENEVER SQLERROR EXIT FAILURE;
EOF
if [ -f oracleHeader.sql ]; then
cat oracleHeader.sql >> $1_oracle_create.sql
fi
if [ -f oracleHeader.sql ]; then
cat oracleHeader.sql >> ${destdir}$1_oracle_create.sql
fi
cat oracleSchema.sql >> $1_oracle_create.sql
cat oracleSchema.sql >> ${destdir}$1_oracle_create.sql
# insert release number
/bin/cat >> $1_oracle_create.sql <<EOF
# insert release number
/bin/cat >> ${destdir}$1_oracle_create.sql <<EOF
/* SQL statements for table UpgradeLog */
CREATE TABLE UpgradeLog (Username VARCHAR2(64) DEFAULT sys_context('USERENV', 'OS_USER') CONSTRAINT NN_UpgradeLog_Username NOT NULL, SchemaName VARCHAR2(64) DEFAULT '$schemaname' CONSTRAINT NN_UpgradeLog_SchemaName NOT NULL, Machine VARCHAR2(64) DEFAULT sys_context('USERENV', 'HOST') CONSTRAINT NN_UpgradeLog_Machine NOT NULL, Program VARCHAR2(48) DEFAULT sys_context('USERENV', 'MODULE') CONSTRAINT NN_UpgradeLog_Program NOT NULL, StartDate TIMESTAMP(6) WITH TIME ZONE DEFAULT systimestamp, EndDate TIMESTAMP(6) WITH TIME ZONE, FailureCount NUMBER DEFAULT 0, Type VARCHAR2(20) DEFAULT 'NON TRANSPARENT', State VARCHAR2(20) DEFAULT 'INCOMPLETE', SchemaVersion VARCHAR2(20) CONSTRAINT NN_UpgradeLog_SchemaVersion NOT NULL, Release VARCHAR2(20) CONSTRAINT NN_UpgradeLog_Release NOT NULL);
......@@ -66,28 +72,22 @@ AS
EOF
# append trailers
if [ -f $1_oracle_create.list ]; then
for f in `cat $1_oracle_create.list`; do
cat $f >> $1_oracle_create.sql
done
else
cat oracleTrailer.sql >> $1_oracle_create.sql
fi
# append trailers
if [ -f $1_oracle_create.list ]; then
for f in `cat $1_oracle_create.list`; do
cat $f >> ${destdir}$1_oracle_create.sql
done
else
cat oracleTrailer.sql >> ${destdir}$1_oracle_create.sql
fi
# flag creation script completion
/bin/cat >> $1_oracle_create.sql <<EOF
# flag creation script completion
/bin/cat >> ${destdir}$1_oracle_create.sql <<EOF
/* Flag the schema creation as COMPLETE */
UPDATE UpgradeLog SET endDate = systimestamp, state = 'COMPLETE';
COMMIT;
EOF
echo Creation script for $1 generated with tag $2
else
# install
cp $1_oracle_create.sql $4
echo Creation script for $1 installed in $4
fi
echo "Creation script for $1 (${destdir}$1_oracle_create.sql) generated with tag $2"
......@@ -70,3 +70,13 @@ CastorAddProC(Cupv_oracle_ifce)
CastorInstallSysconfigExample(cupvd)
CastorInstallLogrotate(castor-upv-server)
endif (${COMPILE_SERVER} STREQUAL "1")
################################################################################
# Rules to build and install the CUPV oracle SQL schema
################################################################################
add_custom_target(cupv_oracle_create.sql ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/makeSqlScripts.sh cupv ${CASTOR_DB_VERSION} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS oracleSchema.sql oracleTrailer.sql
COMMENT Creating cupv_oracle_create.sql
)
CastorInstallSQL(cupv_oracle_create.sql)
......@@ -190,3 +190,13 @@ foreach (CLIENT_EXE ${VMGR_CLIENT_EXES})
endforeach ()
target_link_libraries (vmgrdeletetape castorns)
install(TARGETS ${VMGR_CLIENT_EXES} DESTINATION ${CASTOR_DEST_BIN_DIR})
################################################################################
# Rules to build and install the VMGR oracle SQL schema
################################################################################
add_custom_target(vmgr_oracle_create.sql ALL
COMMAND ${CMAKE_SOURCE_DIR}/tools/makeSqlScripts.sh vmgr ${CASTOR_DB_VERSION} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS oracleSchema.sql oracleTrailer.sql
COMMENT Creating vmgr_oracle_create.sql
)
CastorInstallSQL(vmgr_oracle_create.sql)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment