PhoenixKitBookings.Migrations.Schema (PhoenixKitBookings v0.1.1)

Copy Markdown View Source

Versioned migration for the Bookings module.

Creates the phoenix_kit_bookings_services, phoenix_kit_bookings_availability_rules and phoenix_kit_bookings_bookings tables. All statements use IF NOT EXISTS guards — safe to run multiple times.

Implements the versioned-migration protocol expected by PhoenixKit Core (mix phoenix_kit.update): current_version/0 and migrated_version_runtime/1. Reference implementation — PhoenixKitStats.Migrations.Schema in phoenix_kit_stats.

A booking carries either a timed pair (starts_at/ends_at, minute-unit services) or a date pair (starts_on/ends_on, day/night services) — exactly one, enforced by the bookings_time_shape CHECK. Both pairs are exclusive-end.

Summary

Functions

Target schema version of the Bookings module.

Rolls back the Bookings module migration.

Currently applied schema version, read from the database.

Applies the Bookings module migration.

Functions

current_version()

Target schema version of the Bookings module.

down(opts \\ [])

Rolls back the Bookings module migration.

Accepts a keyword list (the form Core passes) or a map, for backward compatibility.

migrated_version_runtime(opts \\ [])

Currently applied schema version, read from the database.

Returns 0 when the phoenix_kit_bookings_services table does not yet exist, and 1 once it has been created. opts is a keyword list with an optional :prefix.

up(opts \\ [])

Applies the Bookings module migration.

Accepts a keyword list (the form Core passes) or a map, for backward compatibility.