Installation Manifest - I can disabled the journal globals by the XML?

I'm creating a new namespace by the installation manifest XML and in the "database" tag configuration I don't see attribute to configure if I what jounal globals or not to this database.

In the database wizard of the "portal administration", have this option.

Regards,

Lucas Boeing Scarduelli

  • + 3
  • 0
  • 174
  • 7
  • 1

Answers

You can call code from %Installer via Invoke tag (more on that).

To change journaling programmatically execute:

/// Change database journaling state.
/// dbDir - database Directory (can be passed relative to the current working dir)
/// journal - 1 or 0. 1 enables journaling, 0 disables it.
/// zw ##class(util.Test).JournalDB("USER", 1)
ClassMethod JournalDB(dbDir As %String, journal As %Boolean = {$$$YES}) As %Status
{
    quit:((journal<0) || (journal>3)) $$$ERROR($$$GeneralError, "Invalid journal value. 0 or 2 for No, 1 or 3 for Yes")
    set:journal=$$$YES journal=3
    set:journal=$$$NO journal=2

    new $namespace
    set $namespace = "%SYS"
    set db=##Class(SYS.Database).%OpenId(dbDir)
    set db.GlobalJournalState = journal
    quit db.%Save()
}

That said, any particular reason you want unjournaled databases?

Hi, thanks!

We think of doing this way, but it would be more elegant if we had an attribute in the tag <Database>.

This database is created dynamically to CI, so we want unjournaled databases, to not to take up too much disk space.

There is no such attribute in <Database> tag, unfortunately.

Thank you for helping Eduard Lebedyuk.
Lucas Scarduelli and I followed that idea. Just by contributing, we developed the following method:

ClassMethod disableJournaling(databaseDir As %String = "")
{
    #dim database As SYS.Database = ""
    #dim error As %RegisteredObject = ""
    #dim currentNamespace As %String = $namespace
    
    try {
        znspace "%SYS"
        
        set database = ##class(SYS.Database).%OpenId(databaseDir)
        do database.DisableJournaling()
        $$$ThrowOnError(database.%Save())
        
        znspace currentNamespace
    } catch error {
        znspace currentNamespace
        do error.Log()
    }    
}

Are there advantages to using:

set currentNamespace = $namespace
znspace "%SYS"
// do stuff
znspace currentNamespace

Instead of:

new $namespace
set $namespace = "%SYS"
// do stuff

Probably not. But prior to 2010.1 we didn't have $NAMESPACE, and its forerunner $ZNSPACE couldn't be NEWed. So code might look like this:

set currentNamespace = $znspace
znspace "%SYS"
// do stuff
znspace currentNamespace

But prior to 2010.1 we didn't have $NAMESPACE

As @Lucas Fernandes uses $namespace in his solution:

 #dim currentNamespace As %String = $namespace 

that is not a concern in this particular case.