**WARNING**: *This step must be executed only once.*
+Workflow Designer requires two Cassandra namespaces:
+
+- WORKFLOW
+- ZUSAMMEN_WORKFLOW
+
+By default, these keyspaces are configured to use a simple replication strategy (`'class' : 'SimpleStrategy'`)
+and the replication factor of one (`'replication_factor' : 1`). In order to override this configuration, override
+the *create_keyspaces.cql* file at the root of the initialization container using
+[Docker volume mapping](https://docs.docker.com/storage/volumes/). Include `IF NOT EXISTS` clause in the keyspace
+creation statements to prevent accidental data loss.
+
`docker run -ti -e CS_HOST=<cassandra-host> -e CS_PORT=<cassandra-port> -e CS_AUTHENTICATE=true/false
-e CS_USER=<cassandra-user> -e CS_PASSWORD=<cassandra-password> nexus3.onap.org:10001/onap/workflow-init:latest`
RUN pip install cqlsh==4.0.1
-COPY create_workflow_db.cql .
-COPY start.sh .
+COPY create_keyspaces.cql create_tables.cql start.sh ./
RUN chmod 744 start.sh
--- /dev/null
+CREATE KEYSPACE IF NOT EXISTS WORKFLOW
+WITH DURABLE_WRITES = TRUE
+AND REPLICATION = {
+ 'class' : 'SimpleStrategy',
+ 'replication_factor' : 1
+};
+
+CREATE KEYSPACE IF NOT EXISTS ZUSAMMEN_WORKFLOW
+WITH REPLICATION = {
+ 'class' : 'SimpleStrategy',
+ 'replication_factor' : 1
+};
-CREATE KEYSPACE IF NOT EXISTS WORKFLOW
-WITH DURABLE_WRITES = TRUE
-AND REPLICATION = {
- 'class' : 'SimpleStrategy',
- 'replication_factor' : 1
-};
-
USE WORKFLOW;
CREATE TABLE IF NOT EXISTS UNIQUE_VALUE (
PRIMARY KEY (( TYPE, VALUE ))
);
-CREATE KEYSPACE IF NOT EXISTS ZUSAMMEN_WORKFLOW
-WITH REPLICATION = {
- 'class' : 'SimpleStrategy',
- 'replication_factor' : 1
-};
-
USE ZUSAMMEN_WORKFLOW;
CREATE TABLE IF NOT EXISTS ITEM (
PUBLISH_TIME TIMESTAMP,
ACTION TEXT,
PRIMARY KEY (( SPACE, ITEM_ID ), VERSION_ID)
-);
\ No newline at end of file
+);
exit 1
fi
-if [ $is_cs_unauthenticated -eq 1 ]; then
- cqlsh -u ${CS_USER} -p ${CS_PASSWORD} -f /create_workflow_db.cql ${CS_HOST} ${CS_PORT}
-else
- cqlsh -f /create_workflow_db.cql ${CS_HOST} ${CS_PORT}
-fi
+cql_from_file() {
+
+ if [ $is_cs_unauthenticated -eq 1 ]; then
+ cqlsh -u ${CS_USER} -p ${CS_PASSWORD} -f $1 ${CS_HOST} ${CS_PORT}
+ else
+ cqlsh -f $1 ${CS_HOST} ${CS_PORT}
+ fi
+}
+cql_from_file /create_keyspaces.cql
+cql_from_file /create_tables.cql