Forum OpenACS Q&A: Re: Dropping a package

Collapse
7: Re: Dropping a package (response to 1)
Posted by Dave Bauer on
Here is how the process works.

One install of a package, the files in package-key/sql/dbname/ *-create.sql are executed.

These are executed only once when the package is first installed.

When you uninstall the package completey all package instances are removed, and the package will be unavailable for use. This is the only time the *-drop.sql scripts are run.

When you want to delete one package instance, the drop scripts are not run. There are APM Tcl callbacks that can be executed when a package is deleted. See /acs-admin/apm/ click on a packgae name, then on #
# Tcl Callbacks (install, instantiate, mount)

There is a callback for the following events:

before-install
after-install
before-upgrade
after-upgrade
before-uninstall
after-instantiate
before-uninstantiate
after-mount
before-unmount

In the case of deleting one package instnace the callback to use is before-uninstantiate. In the before-uninstantiate callback, all objects that refer to the package_id of the pakcage instance must be removed or otherwise dereferenced from that package_id. At this time most packages do not handle this correctly. Basically what needs to be done is run code similar to the drop.sql script just for one package_id.

If you visit the callback page for one package, you can get more information about how the callbacks work, and when they are executed.

All packages should implement the before uninstantiate callback to allow delete of package instances.