Database cleaning script – XG, DG, LTV and user tables

Use this script to securely remove contents from the FormFlow installation and restore it to the default state based on the parameters specified. The script only removes the contents, not settings.

The script is located at c:\wwwroot\[FormFlow]\utils\clean_ffs_installation.php.

Usage:

php -f cleanup_ffs_installation.php [-h] [-l logfile] [-d] [-f] [-a]

This script removes all objects of a given type from the FormFlow installation.

-h

displays the help

-l logfile

the file where the script will write its log

-d

delete all DG documents

-f

delete all forms (processes)

-a

delete all address book entries

Implementation

The classes are in folder htdocs\FS\Common\Cleanup. The main class is CleanupManager, permissions are checked by the CleanupAuthorizator, the operation is performed by the CleanupService class. Operation is configured by an instance of class CleanupConfiguration.

The operation must be run in two steps:

  • In the first step and in a database transaction, the entries selected for removal are removed, see method CleanupManager::cleanup().

  • In the second step and outside a database transaction, the column sequences or IDENTITIES are restarted - see method CleanupManager::restartSequencesOrIDENTITYColumns(). See also the script cleanup_ffs_installation.php, where this is called.

The database contents are modified by classes-modules.

  • They are located at htdocs\FS\Common\Cleanup\Modules.

  • These classes are called from the CleanupService class.

  • The modules must implement the interface \FS\Common\Cleanup\Modules\IModule.

  • They should be children of class \FS\Common\Cleanup\Modules\BaseModule, because the class provides the methods useful when modifying the database contents.

The following two modules are implemented:

  • \FS\Common\Cleanup\Modules\DGDocumentsModule – deletes DG documents.

  • \FS\Common\Cleanup\Modules\FormsModule – deletes forms.

All the above listed classes are services in the system container – see file: htdocs\configs\DI\config.neon.

Implementing another module

  • Check and, if needed, add parameters to class CleanupConfiguration.

  • Create a class-module in folder htdocs\FS\Common\Cleanup\Modules.

    • It must implement the \FS\Common\Cleanup\Modules\IModule interface.

    • Should be a child of the \FS\Common\Cleanup\Modules\BaseModule class.

    • Add it to config.neon.

    • Its operation can be logged using the \FS\Common\Cleanup\CleanupLog class, whose instance is provided to both the methods, cleanup() and restartSequencesOrIDENTITYColumns().

  • Edit the CleanupService class, which also means that the CleanupService will receive an instance of the new class-module in its constructor. In the cleanup() and restartSequencesOrIDENTITYColumns() methods, the corresponding methods of the new class-module must be called.