Enable Database Log on all Parameter- and Group-Tables

I want to make sure that I know who changed what and when on all parameter- and group-tables.

The following script will enable the database log on all those tables:

static void enableDatabaselogOnParameterTables(Args _args)
{
    #AOT
    DatabaseLog         databaseLog;
    TreeNode            treeNode;
    SysDictTable        sysDictTable;
    Name                name;
    ;
    ttsbegin;
    treeNode = TreeNode::findNode(#TablesPath);
    treeNode = treeNode.AOTfirstChild();
    while (treeNode)
    {
        name = treeNode.AOTname();
        sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());
        if((sysDictTable.tableGroup() == TableGroup::Parameter || sysDictTable.tableGroup() == TableGroup::Group)
            && SysQueryForm::hasValidCountryCode(sysDictTable.id()))
        {
            select firstOnly databaseLog where databaseLog.logTable == sysDictTable.id(); //do not modify existing settings
            if(!databaseLog)
            {
                databaseLog.LogTable = sysDictTable.id();
                databaseLog.LogField = 0;
                databaseLog.LogType = DatabaseLogType::Update;
                databaseLog.insert();
                databaseLog.LogType = DatabaseLogType::EventUpdate;
                databaseLog.insert();
                if(sysDictTable.tableGroup() != TableGroup::Parameter)
                {
                    databaseLog.LogType = DatabaseLogType::Delete;
                    databaseLog.insert();
                    databaseLog.LogType = DatabaseLogType::EventDelete;
                    databaseLog.insert();
                    databaseLog.LogType = DatabaseLogType::RenameKey;
                    databaseLog.insert();
                    databaseLog.LogType = DatabaseLogType::EventRenameKey;
                    databaseLog.insert();
                    databaseLog.LogType = DatabaseLogType::Insert;
                    databaseLog.insert();
                    databaseLog.LogType = DatabaseLogType::EventInsert;
                    databaseLog.insert();
                }
            }
        }
        treeNode = treeNode.AOTnextSibling();
    }
    ttscommit;
    SysFlushDatabaseLogSetup::main();
}
Advertisements