diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/mssql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/mssql.sql index 1f299821..7d2a7a84 100644 --- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/mssql.sql +++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/mssql.sql @@ -17,11 +17,15 @@ */ --For account metadata feature run the following queries against the openbank_openbankingdb-- -CREATE TABLE IF NOT EXISTS OB_ACCOUNT_METADATA ( - ACCOUNT_ID VARCHAR(100) NOT NULL, - USER_ID VARCHAR(100) NOT NULL, - METADATA_KEY VARCHAR(100) NOT NULL, - METADATA_VALUE VARCHAR(100) NOT NULL, - LAST_UPDATE_TIMESTAMP DATETIME NOT NULL DEFAULT getdate(), - PRIMARY KEY (USER_ID,ACCOUNT_ID,METADATA_KEY) -); +IF OBJECT_ID('dbo.OB_ACCOUNT_METADATA', 'U') IS NULL +BEGIN +CREATE TABLE dbo.OB_ACCOUNT_METADATA +( +ACCOUNT_ID varchar(100) NOT NULL, +USER_ID varchar(100) NOT NULL, +METADATA_KEY varchar(100) NOT NULL, +METADATA_VALUE varchar(100) NOT NULL, +LAST_UPDATED_TIMESTAMP timestamp NOT NULL, +CONSTRAINT OB_ACCOUNT_USER_ATTRIBUTE_PK PRIMARY KEY (USER_ID,ACCOUNT_ID,METADATA_KEY) +) +END; diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/oracle.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/oracle.sql index 6af8031c..8fcc9338 100644 --- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/oracle.sql +++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/oracle.sql @@ -22,6 +22,6 @@ CREATE TABLE IF NOT EXISTS OB_ACCOUNT_METADATA ( USER_ID varchar(100) NOT NULL, METADATA_KEY varchar(100) NOT NULL, METADATA_VALUE varchar(100) NOT NULL, - LAST_UPDATE_TIMESTAMP timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + LAST_UPDATED_TIMESTAMP timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (USER_ID,ACCOUNT_ID,METADATA_KEY) ); diff --git a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/postgresql.sql b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/postgresql.sql index 65e375bd..8a22ac8e 100644 --- a/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/postgresql.sql +++ b/open-banking-accelerator/accelerators/ob-is/carbon-home/dbscripts/open-banking/account-metadata/postgresql.sql @@ -22,6 +22,6 @@ CREATE TABLE IF NOT EXISTS OB_ACCOUNT_METADATA ( USER_ID varchar(100) NOT NULL, METADATA_KEY varchar(100) NOT NULL, METADATA_VALUE varchar(100) NOT NULL, - LAST_UPDATE_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (USER_ID,ACCOUNT_ID,METADATA_KEY) );