reservation.upgrade =================== .. py:module:: reservation.upgrade .. autoapi-nested-parse:: Contains upgrade tasks that are executed when the application is being upgraded on the server. See :class:`onegov.core.upgrade.upgrade_task`. Functions --------- .. autoapisummary:: reservation.upgrade.run_upgrades reservation.upgrade.add_form_definition_field reservation.upgrade.add_resource_group_field reservation.upgrade.add_reservations_allocations_type_field reservation.upgrade.make_reservations_allocations_payable reservation.upgrade.set_defaults_on_existing_reservation_resourcd_objects reservation.upgrade.add_access_token_to_existing_resources reservation.upgrade.add_default_view_to_existing_resource_types reservation.upgrade.make_resource_polymorphic_type_non_nullable reservation.upgrade.add_resource_subgroup_column reservation.upgrade.migrated_text_based_json_to_jsonb reservation.upgrade.translate_default_views_to_their_new_names reservation.upgrade.add_source_type_column_to_reserved_slots reservation.upgrade.make_allocation_and_reservation_type_not_nullable reservation.upgrade.add_resource_parent_id_column reservation.upgrade.add_reserved_slots_indeces reservation.upgrade.add_additional_indexes_to_libres_tables reservation.upgrade.resources_switch_to_parsed_form reservation.upgrade.backfill_reserved_slot_source_ids reservation.upgrade.add_source_id_to_reserved_slots reservation.upgrade.store_pricing_settings_on_reservations_fixed reservation.upgrade.migrate_resources_parent_id_to_association_table Module Contents --------------- .. py:function:: run_upgrades(context: onegov.core.upgrade.UpgradeContext) -> bool onegov.reservation is a bit special because it defines its tables through its own declarative base. This is due to libres requireing its own base. As a consequence, not all applications loaded in the current process have all the tables for all the modules (which is usually the case for all onegov modules using the default onegov.core.orm.Base class). This means we can only run the upgrades if Libres is integrated with the current app. .. py:function:: add_form_definition_field(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_resource_group_field(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_reservations_allocations_type_field(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: make_reservations_allocations_payable(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: set_defaults_on_existing_reservation_resourcd_objects(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_access_token_to_existing_resources(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_default_view_to_existing_resource_types(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: make_resource_polymorphic_type_non_nullable(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_resource_subgroup_column(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: migrated_text_based_json_to_jsonb(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: translate_default_views_to_their_new_names(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_source_type_column_to_reserved_slots(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: make_allocation_and_reservation_type_not_nullable(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_resource_parent_id_column(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_reserved_slots_indeces(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: add_additional_indexes_to_libres_tables(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: resources_switch_to_parsed_form(context: onegov.core.upgrade.UpgradeContext) -> None .. py:function:: backfill_reserved_slot_source_ids(session: Any) -> None Sets ``source_id`` on every reserved slot to the id of its owning reservation/blocker, and deletes slots that belong to no object (orphans left behind when a reservation/blocker was deleted without its slots). On partly_available allocations the slot falls within the owner's range; otherwise (whole allocation, or group owners without a range) the allocation group identifies the owner. .. py:function:: add_source_id_to_reserved_slots(context: onegov.core.upgrade.UpgradeContext) -> None Records the owning reservation/blocker id on each reserved slot so a slot can be attributed to its exact object directly, instead of inferring it from the allocation and time range. Slots that belong to no object are orphans (their reservation/blocker was already deleted) and are removed. .. py:function:: store_pricing_settings_on_reservations_fixed(context: onegov.core.upgrade.UpgradeContext) -> None Snapshots each reservation's pricing onto its own ``data``, from the master allocation when it defines a price, otherwise from the resource content. Re-run of `Store pricing settings on reservations` under a new name so it executes again on already-upgraded databases. Three bugs in the original zeroed prices: - the allocation lookup matched on the wrong ``pricing_method`` constants (``price_per_item``/``price_per_hour`` instead of ``per_item``/ ``per_hour``), so allocation-priced reservations never matched, - the ``resource = mirror_of`` guard was mis-parenthesised (``AND`` bound tighter than the following ``OR``s), and - the resource-content fallback read ``content->'price_per_item'``, but the resource stores that value under ``price_per_reservation``. .. py:function:: migrate_resources_parent_id_to_association_table(context: onegov.core.upgrade.UpgradeContext) -> None