reservation.upgrade

Contains upgrade tasks that are executed when the application is being upgraded on the server. See onegov.core.upgrade.upgrade_task.

Functions

run_upgrades(→ bool)

onegov.reservation is a bit special because it defines its tables

add_form_definition_field(→ None)

add_resource_group_field(→ None)

add_reservations_allocations_type_field(→ None)

make_reservations_allocations_payable(→ None)

set_defaults_on_existing_reservation_resourcd_objects(→ None)

add_access_token_to_existing_resources(→ None)

add_default_view_to_existing_resource_types(→ None)

make_resource_polymorphic_type_non_nullable(→ None)

add_resource_subgroup_column(→ None)

migrated_text_based_json_to_jsonb(→ None)

translate_default_views_to_their_new_names(→ None)

add_source_type_column_to_reserved_slots(→ None)

make_allocation_and_reservation_type_not_nullable(→ None)

add_resource_parent_id_column(→ None)

add_reserved_slots_indeces(→ None)

add_additional_indexes_to_libres_tables(→ None)

resources_switch_to_parsed_form(→ None)

backfill_reserved_slot_source_ids(→ None)

Sets source_id on every reserved slot to the id of its owning

add_source_id_to_reserved_slots(→ None)

Records the owning reservation/blocker id on each reserved slot so a

store_pricing_settings_on_reservations_fixed(→ None)

Snapshots each reservation's pricing onto its own data, from the

migrate_resources_parent_id_to_association_table(→ None)

Module Contents

reservation.upgrade.run_upgrades(context: onegov.core.upgrade.UpgradeContext) bool[source]

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.

reservation.upgrade.add_form_definition_field(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_resource_group_field(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_reservations_allocations_type_field(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.make_reservations_allocations_payable(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.set_defaults_on_existing_reservation_resourcd_objects(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_access_token_to_existing_resources(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_default_view_to_existing_resource_types(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.make_resource_polymorphic_type_non_nullable(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_resource_subgroup_column(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.migrated_text_based_json_to_jsonb(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.translate_default_views_to_their_new_names(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_source_type_column_to_reserved_slots(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.make_allocation_and_reservation_type_not_nullable(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_resource_parent_id_column(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_reserved_slots_indeces(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.add_additional_indexes_to_libres_tables(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.resources_switch_to_parsed_form(context: onegov.core.upgrade.UpgradeContext) None[source]
reservation.upgrade.backfill_reserved_slot_source_ids(session: Any) None[source]

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.

reservation.upgrade.add_source_id_to_reserved_slots(context: onegov.core.upgrade.UpgradeContext) None[source]

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.

reservation.upgrade.store_pricing_settings_on_reservations_fixed(context: onegov.core.upgrade.UpgradeContext) None[source]

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.

reservation.upgrade.migrate_resources_parent_id_to_association_table(context: onegov.core.upgrade.UpgradeContext) None[source]