Updating Oracle NoSQL Table Using Terraform and OCI Resource Manager

In this article, we will see the steps to update an existing NDCS Table schema or storage (read or write) units using Terraform. We will use the OCI Resource Manager CLI to update NDCS Tables. Before we proceed with this article, it is assumed that you are aware of NoSQL Cloud Service and know its basics, along with Terraform.

The first step is to create the override file with the necessary configuration changes. And then run the Resource Manager CLI commands to perform the following tasks:
  • Update a stack.
  • Generate and review the execution plan.
  • Run the Apply job to update the required NoSQL resources.
  • Review log files, as needed.

This article has the following topics:

Prerequisites

  • An existing stack with NoSQL Database resources such as tables or indexes.
  • Existing Terraform Configuration files used for creating NoSQL Database resources such as tables or indexes.

Step 1: Create Terraform Override files for NoSQL Database Table

Create a new file named "nosql_override.tf" or "override.tf" and provide the specific portion of the NoSQL Database table object that you want to override. For example, you may want to add or drop a column from the table change the data type of an existing column, or change table limits (read/write and storage units).

In the example below, we are going to modify the demo table to drop an existing column, named fullName, and modify the demoKeyVal table to add a new column, named shortName.

For example:

If you have a Terraform configuration nosql.tf with the following contents:
variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, fullName STRING, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
    name = "demo"
    table_limits {
        max_read_units = var.table_table_limits_max_read_units
        max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
        max_write_units = var.table_table_limits_max_write_units
    }
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))"
    name = "demoKeyVal"
    table_limits {
       max_read_units = var.table_table_limits_max_read_units
        max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
        max_write_units = var.table_table_limits_max_write_units
    }
}
You now want to modify the demo table and drop an existing column, named fullName, and modify the demoKeyVal table to add a new column, named shortName. Then create a file nosql_override.tf or override.tf containing the following content:
variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, contactPhone STRING,
    confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
    name = "demo"   
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY 
    (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, shortName STRING, PRIMARY KEY (key))"
    name = "demoKeyVal"  
}

When Terraform processes this file (nosql_override.tf), internally it parses the DDL statement (CREATE TABLE statement) and compares it with the existing table definition and generates an equivalent ALTER TABLE statement, and applies it.

Step 2: Update the Execution Plan

Note:

These instructions don't apply to configurations stored in source code control systems. If you are using source code control systems such as GitHub and Gitlab to maintain terraform configuration files, you can skip this step and directly move to Step 3. The latest version of your configuration is automatically used by any job running on the associated stack.
For this tutorial, we are going to update the execution plan with the updated terraform configuration zip file, terraform.zip file. The updated terraform.zip file contains the following files:
  • provider.tf
  • nosql.tf
  • nosql_override.tf or override.tf
  • terraform.tfvars
  • variables.tf
For example:
oci resource-manager stack update 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq 
--config-source terraform.zip
Example response:
{
  "data": {
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-type": "ZIP_UPLOAD",
      "working-directory": null
    },
    "defined-tags": {},
    "description": null,
    "display-name": "ormstack20220117104810",
    "freeform-tags": {},
    "id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq", 
    "lifecycle-state": "ACTIVE",
    "stack-drift-status": "NOT_CHECKED",
    "terraform-version": "1.0.x",
    "time-created": "2022-01-17T10:48:10.878000+00:00",
    "time-drift-last-checked": null,
    "variables": {}
  },
  "etag": "068e7b962aa43c7b3e7bf5c24b2d7f937db0901a784a9dce8715d76d78ad30f3"
}

We have updated an existing stack with the new updated zip file containing override terraform configuration file(s).

Step 3: Generate an Execution Plan

To generate an execution plan, run the following command:
oci resource-manager job create-plan-job 
–-stack-id <stack_OCID> 
--display-name "<friendly_name>"
For example:
oci resource-manager job create-plan-job 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq
Example response:
{
  "data": {
    "apply-job-plan-resolution": null,
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "ormjob20220124122310",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
    "job-operation-details": {
      "operation": "PLAN",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "ACCEPTED",
    "operation": "PLAN",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-24T12:23:10.366000+00:00",
    "time-finished": null,
    "variables": {},
    "working-directory": null
  },
  "etag": "b77d497287af3dd2d166871457d880ffee9952ee2c9a44e8f9dfa3e02b974c95"
}
We have generated an execution plan from a stack. The Resource Manager creates a job with a unique id corresponding to this execution plan. This plan job id can be used later to review the execution plan details before running the apply operation to deploy the NoSQL database resources on the OCI cloud.
"id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
"job-operation-details": {
      "operation": "PLAN"
      ...
}

Substep 3.1: Review the Execution Plan

To review an execution plan, run the following command:
oci resource-manager job get-job-logs 
--job-id <plan_job_OCID>
For example:
oci resource-manager job get-job-logs 
--job-id ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia
Example response:
...
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demo will be read during apply",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demo\"  {",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ is_auto_reclaimable = true -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "          - \"orcl-cloud.free-tier-retained\" = \"true\"",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demoKeyVal will be read during apply",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\"  {",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ is_auto_reclaimable = true -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demo will be updated in-place",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, PRIMARY KEY(SHARD(key)))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ nosql_table_ddl_statement    = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
...
This step is very important as it validates if the updated stack code contains any syntax errors, and exactly how many OCI resources are being added, updated, or destroyed. In the tutorial, we are updating the schema of two NoSQL tables: demo and demoKeyVal by adding and dropping column(s)..
{
 ...
      "message": "Plan: 0 to add, 2 to change, 0 to destroy.",
 ...
}

Step 4: Run an Apply Job

  • To specify a plan job ("apply" an execution plan), use FROM_PLAN_JOB_ID:
    oci resource-manager job create-apply-job 
    --stack-id <stack_OCID> 
    --execution-plan-strategy FROM_PLAN_JOB_ID 
    --execution-plan-job-id <plan_job_OCID> 
    --display-name "Example Apply Job"
  • To automatically approve the apply job (no plan job specified), use AUTO_APPROVED:
    oci resource-manager job create-apply-job 
    --stack-id <stack_OCID> 
    --execution-plan-strategy AUTO_APPROVED 
    --display-name "Example Apply Job"
For example:
oci resource-manager job create-apply-job 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq 
--execution-plan-strategy AUTO_APPROVED 
--display-name "Update NoSQL Tables Using Terraform"
Example response:
{
  "data": {
    "apply-job-plan-resolution": {
      "is-auto-approved": true,
      "is-use-latest-job-id": null,
      "plan-job-id": null
    },
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "Update NoSQL Tables Using Terraform",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq",
    "job-operation-details": {
      "execution-plan-job-id": null,
      "execution-plan-strategy": "AUTO_APPROVED",
      "operation": "APPLY",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "ACCEPTED",
    "operation": "APPLY",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-24T12:36:52.911000+00:00",
    "time-finished": null,
    "variables": {},
    "working-directory": null
  },
  "etag": "b2af026af48897c7839c347e06a8c40ec3ce1cac08a3da2f0c6ee74fb07078ab"
}

Substep 4.1: Verify the Status of Job

To verify the status of a job, run the following command:
oci resource-manager job get 
--job-id <job_OCID>
For example:
oci resource-manager job get 
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
Example response:
{
  "data": {
    "apply-job-plan-resolution": {
      "is-auto-approved": true,
      "is-use-latest-job-id": null,
      "plan-job-id": null
    },
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "ALTER NoSQL Table Schema",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq",
    "job-operation-details": {
      "execution-plan-job-id": null,
      "execution-plan-strategy": "AUTO_APPROVED",
      "operation": "APPLY",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "SUCCEEDED",
    "operation": "APPLY",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-20T11:14:13.916000+00:00",
    "time-finished": "2022-01-20T11:14:51.921000+00:00",
    "variables": {},
    "working-directory": null
  },
  "etag": "13b1253bd5e6ca78778b4cf6aad38d262b1476aae06e6f36b40b5f914016b899--gzip"
}
You can check the status of your apply job to verify if the job is SUCCESSFUL or FAILED.
{
...
      "lifecycle-state": "SUCCEEDED",
...
}

Substep 4.2: View the Log for a Job

To view the log for a job, run the following command:
oci resource-manager job get-job-logs-content 
--job-id <job_OCID>
For example:
oci resource-manager job get-job-logs-content
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
Example response:
...
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demoKeyVal: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "plan. Resource actions are indicated with the following symbols:",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ update in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Terraform will perform the following actions:",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demo will be read during apply",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demo\"  {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + compartment_id      = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + table_name_or_id    = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\"  {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + compartment_id      = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + table_name_or_id    = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demo will be updated in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        name                = \"demo\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        name                = \"demoKeyVal\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Plan: 0 to add, 2 to change, 0 to destroy.",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demoKeyVal: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:27.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:27.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Modifications complete after 9s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demo: Reading...",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demo: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demoKeyVal: Reading...",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demoKeyVal: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\"",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "nosql_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\"",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
... 
This step is very important as it confirms exactly how many OCI resources were added, updated, or destroyed. In the tutorial, we have successfully updated the schema of the two NoSQL tables: demo and demoKeyVal.
{
 ...
      "message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
 ...
}

We have covered a lot of details in this tutorial. We created override terraform configuration files required for updating the schema of NoSQL database tables on OCI cloud and then used the OCI Resource Manager CLI to update the existing stack, generate an execution plan, and run apply job on the execution plan.