Have two (or more) Audit Store databases in the Audit Store viz. "Database A" and "Database B". "Database A" (referred to as "old Audit Store database" in this document) was active Audit Store database for some time after which "Database B" was created and set as active database. Now, want to make "Database A" active again.
Design limitation -
DA does not allow recycling the previously active Audit Store database. If a database has been previously active, it cannot be made active again using the Administrator console. This is because there are two conditions that are checked by DA before it can mark the database as active:
Condition#1 - The database to be marked as active must be empty.
Condition#2 - The database must not be in the history of previously active Audit Store databases.
The workaround is to fix Condition#1 and Condition#2 specified above so that the old database can be marked as active again.
!!!IMPORTANT!!! - Before proceeding with step#1, please make sure that the database recovery mode is set to "Simple" on the old Audit Store database that you want to reactivate.
Step#1 - Clear all the session data from the database that wanted to reactivate. Before this step, take a full backup of the old Audit Store database in case if needed to retrieve the sessions in future. Once the backup is ready, use one of the two approaches to clear the session data from the old Audit Store database.
1. Run the following SQL command on the old database,
DELETE FROM dbo.Session
Please note that deleting any entries from Session table results into a cascade delete operation and it may take a lot of time on a large database. Please see
Step #2 for a faster approach.
2. Run the following SQL commands on the old database,
TRUNCATE TABLE dbo.Argument
TRUNCATE TABLE dbo.Command
TRUNCATE TABLE dbo.RawData
TRUNCATE TABLE dbo.SessionDetail
TRUNCATE TABLE dbo.Snapshot
TRUNCATE TABLE dbo.Status
TRUNCATE TABLE dbo.WashData
TRUNCATE TABLE dbo.WashEvent
DELETE FROM dbo.Session
3. (Optional) Run the following SQL command on the old database and make sure it returns 0 (zero) results,
SELECT COUNT(*) FROM dbo.Session
Step#3 - Clear the history. Use the steps below to remove the old Audit Store database from history of active Audit Store databases.
1. Run the following SQL command on the Audit Server database (CentrifyDA_Audit_Server_Prod) and note down the unique identifier of the old database,
SELECT [Guid] FROM dbo.AuditStoreDatabase WHERE [Database] = '<OLD_DATABASE_NAME>' AND [Server] = '<DATABASE_SERVER_NAME>'
SELECT [Guid] FROM dbo.AuditStoreDatabase WHERE [Database] = 'CentrifyDA_AuditStore_Prod_2013_Q1' AND [Server] = 'wsqlrib00001211.corp.internal.citizen'
2. Run the following SQL command on the same Audit Server database to clear the history,
DELETE FROM dbo.AuditStoreActiveDatabaseHistory WHERE [Guid]='<GUID_RETURNED_BY_PREV_COMMAND>'
DELETE FROM dbo.AuditStoreActiveDatabaseHistory WHERE [Guid]='C5C5C623-E82D-4CC1-A736-6ED3ECF4BBEC'
Step#4 - Open the DirectAudit 2012 Administrator Console and right click on the old Audit Store database. Click on the "Set as Active" option to make the database active again.