apm_upgrade_logic (public)

 apm_upgrade_logic -from_version_name from_version_name \
    -to_version_name to_version_name -spec spec

Defined in packages/acs-tcl/tcl/apm-install-procs.tcl

Logic to help upgrade a package. The spec contains a flat list of triples of the form { "from_version" "to_version" "code_chunk" "from_version" "to_version" "code_chunk ..." }. The list is compared against the "from_version_name" and "to_version_name" parameters supplied, and the code_chunks that fall within the from_version_name and to_version_name it'll get executed in the caller's namespace, ordered by the from_version.

Example:


    ad_proc my_upgrade_callback {
        {-from_version_name:required}
        {-to_version_name:required}
    } {
        apm_upgrade_logic  -from_version_name $from_version_name  -to_version_name $to_version_name  -spec {
                1.1 1.2 {
                    ...
                }
                1.2 1.3 {
                    ...
                }
                1.4d 1.4d1 {
                    ...
                }
                2.1 2.3 {
                    ...
                }
                2.3 2.4 {
                    ...
                }
            }
    }

    

Switches:
-from_version_name (required)
The version you're upgrading from, e.g. '1.3'.
-to_version_name (required)
The version you're upgrading to, e.g. '2.4'.
-spec (required)
The code chunks in the format described above
Author:
Lars Pind

Partial Call Graph (max 5 caller/called nodes):
%3 acs_mail_lite::after_upgrade acs_mail_lite::after_upgrade (private) apm_upgrade_logic apm_upgrade_logic acs_mail_lite::after_upgrade->apm_upgrade_logic auth::after_upgrade auth::after_upgrade (private) auth::after_upgrade->apm_upgrade_logic bug_tracker::install::package_upgrade bug_tracker::install::package_upgrade (private) bug_tracker::install::package_upgrade->apm_upgrade_logic calendar::apm::package_after_upgrade calendar::apm::package_after_upgrade (private) calendar::apm::package_after_upgrade->apm_upgrade_logic calendar::install::package_upgrade calendar::install::package_upgrade (private) calendar::install::package_upgrade->apm_upgrade_logic apm_version_names_compare apm_version_names_compare (public) apm_upgrade_logic->apm_version_names_compare

Testcases:
No testcase defined.
Source code:
    if { [llength $spec] % 3 != 0 } {
        error "The length of spec should be dividable by 3"
    }

    array set chunks [list]
    foreach { elm_from elm_to elm_chunk } $spec {

        # Check that
        # from_version_name < elm_from < elm_to < to_version_name

        ns_log notice "apm_upgrade_logic: 1 [list apm_version_names_compare $from_version_name $elm_from] => [apm_version_names_compare $from_version_name $elm_from] <= 0 --> [expr {[apm_version_names_compare $from_version_name $elm_from] <= 0}]"
        ns_log notice "apm_upgrade_logic: 2 [list apm_version_names_compare $elm_from $elm_to] => [apm_version_names_compare $elm_from $elm_to]  <= 0 --> [expr {[apm_version_names_compare $elm_from $elm_to] <= 0}]"
        ns_log notice "apm_upgrade_logic: 3 [list apm_version_names_compare $elm_to $to_version_name] => [apm_version_names_compare $elm_to $to_version_name] <= 0 --> [expr {[apm_version_names_compare $elm_to $to_version_name] <= 0}]"

        if { [apm_version_names_compare $from_version_name $elm_from] <= 0
             && [apm_version_names_compare $elm_from $elm_to] <= 0
             && [apm_version_names_compare $elm_to $to_version_name] <= 0
         } {
            set chunks($elm_from,$elm_to$elm_chunk
        }
    }

    foreach key [lsort -increasing -command apm_upgrade_logic_compare [array names chunks]] {
        uplevel $chunks($key)
    }
Generic XQL file:
packages/acs-tcl/tcl/apm-install-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/apm-install-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/apm-install-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: