Database Upgradability
The Database Upgrade transforms an existing database schema to an updated version. The Database upgrade supports the following operations:
- Adding new collections
- Adding new fields to the existing collection
- Adding indexes to fields of collection
The database upgrade feature is executed in the Microservice framework in diverse ways based on the user requirements. This is implemented in all the stacks K8 , Azure, and AWS.
The APPINIT component is introduced by MSF to support database upgradability. If the MS is a new installation for the client, the APPINIT component helps in creating the tables in the database.
The Following are the versions from which the upgrade is supported to 202301 and higher versions.
- 202110-202204
- 202204-202207
- 202207-202210
- 202210-202301
The client can upgrade from 202110, 202204, 202207, and 202210 to 202301 and higher versions. All the scripts which help in database upgrades are committed to the source and will be available as part of the package under the database/scripts/migration folder.
Azure
A new function app is introduced for APPINIT. Following URL is invoked to run the API in the function app and this upgrades the database.
https://${APPINIT_NAME}.azurewebsites.net/api/v1.0.0/dbmigration?code=${MASTER_KEY}
The following properties are mandatory properties that are to be set for the function app.
--settings DATABASE_NAME=$DATABASE_NAME DB_CONNECTION_URL=$DB_CONNECTION_URL DRIVER_NAME=$DRIVER_NAME DIALECT=$DIALECT DB_PASSWORD=$DB_PASSWORD DB_USERNAME=$DB_USERNAME DATABASE_KEY="sql" temn_msf_name=$MSF_NAME tem_msf_disableInbox=$TEM_APPINIT_DISABLEINBOX temn_msf_security_authz_enabled=$APPINIT_AUTHZ_ENABLED temn_msf_database_auto_upgrade=$DB_AUTO_UPGRADE JPA_ENABLED=$JPA_ENABLED MIN_POOL_SIZE=1 MAX_POOL_SIZE=10
AWS
Lambda function and API Gateway for phms-appinit-initiate and phms-appinit-getstatus are created for APPINIT. The following API is invoked to upgrade database.
https://${restAPIId}.execute-api.$AWS_REGION.amazonaws.com/ms-portfolioholdings-api/v1.0.0/migration -H "x-api-key: ${apiKeyValue}"
The following properties are to be set for the Lamda functions.
--environment Variables=\{DRIVER_NAME=com.mysql.jdbc.Driver,DIALECT=org.hibernate.dialect.MySQL5InnoDBDialect,HOST=${host},PORT=${port},DATABASE_NAME=${dbname},DB_USERNAME=root,DB_PASSWORD=password,DB_CONNECTION_URL=jdbc:mysql://${host}:${port}/campaign,DATABASE_KEY=sql,temn_msf_security_authz_enabled=false,className_initiateDbMigration=com.temenos.microservice.framework.dbmigration.core.InitiateDbMigrationImpl,class_inbox_dao=com.temenos.microservice.framework.core.inbox.InboxDaoImpl,class_outbox_dao=com.temenos.microservice.framework.core.outbox.OutboxDaoImpl,tem_msf_disableInbox=true,temn_msf_database_auto_upgrade=N,MIN_POOL_SIZE=5,MAX_POOL_SIZE=10,JPA_ENABLED=none\}
K8
In the K8 Deployment Scripts, the APPINIT component is to be installed. To install the component, the following properties need to be configured in the helm job.
env:
- name: database.key
value: {{ .Values.env.sqlinit.databaseKey }}
- name: database.name
value: {{ .Values.env.sqlinit.databaseName }}
- name: db.driver.name
value: {{ .Values.env.sqlinit.dbdriver }}
- name: db.dialect
value: {{ .Values.env.sqlinit.dbdialect }}
- name: db.connection.url
value: {{ .Values.env.sqlinit.dbconnectionurl }}
- name: db.auto.upgrade
value: {{ .Values.env.sqlinit.dbautoupgrade | quote }}
- name: temn.msf.database.auto.upgrade
value: {{ .Values.env.sqlinit.dbautoupgrade | quote }}
- name: temn.msf.logger.exportType
value: {{ .Values.env.sqlinit.exportType }}
- name: temn.msf.logger.socketHost
value: {{ .Values.env.sqlinit.socketHost | quote }}
- name: temn.msf.logger.socketPort
value: {{ .Values.env.sqlinit.socketPort | quote }}
- name: spring.profiles.active
value: {{ .Values.env.sqlinit.springProfile }}
{{- if eq .Values.env.dbcred "Y" }}
- name: db.username
valueFrom:
secretKeyRef:
name: appinitsecret
key: USER_NAME
- name: db.password
valueFrom:
secretKeyRef:
name: appinitsecret
key: PASSWORD
{{ else }}
- name: db.username
value: {{ .Values.env.sqlinit.dbusername }}
- name: db.password
value: {{ .Values.env.sqlinit.dbpassword }}
{{- end }}
restartPolicy: {{ .Values.restartPolicy }}
In this topic