AuroraMeter. Migration
(Aurora Meter v0.4.0)
View Source
Creates and drops the Aurora Meter core tables, in versions.
A host migration delegates here, so schema changes ship as new versions of
this module rather than as edits to the host's migration file. Every version
is idempotent (create_if_not_exists), so up/1 can safely run from version 1
each time.
Fresh install (generated by mix aurora_meter.gen.migration):
def up, do: AuroraMeter.Migration.up()
def down, do: AuroraMeter.Migration.down()Upgrading an existing install to a newer schema version, add a migration that runs only the new versions:
def up, do: AuroraMeter.Migration.up(from: 3)
def down, do: AuroraMeter.Migration.down(to: 3)Versions
- 1 —
aurora_meter_subscriptions,aurora_meter_counters,aurora_meter_events - 2 —
aurora_meter_history(UTC day buckets forAuroraMeter.history/3) - 3 —
aurora_meter_credit_balances,aurora_meter_credit_transactions(the prepaid ledger behindAuroraMeter.Credits) - 4 —
promotional_afteronaurora_meter_credit_transactions, so the promotional figure can be rebuilt from the log likebalanceandheld - 5 — a partial index on open holds, so the sweep for reservations nothing will ever close does not scan the whole ledger
- 6 —
aurora_meter_flush_receipts, committed atomically with counter and history deltas to deduplicate retries after uncertain writes
Summary
Functions
Runs the down step of every version from :version (default the latest)
down to :to (default 1).
The newest schema version this release of Aurora Meter knows about.
Runs the up step of every version from :from (default 1) to :version
(default the latest).
Functions
@spec down(keyword()) :: :ok
Runs the down step of every version from :version (default the latest)
down to :to (default 1).
@spec latest_version() :: pos_integer()
The newest schema version this release of Aurora Meter knows about.
Examples
iex> AuroraMeter.Migration.latest_version()
6
@spec up(keyword()) :: :ok
Runs the up step of every version from :from (default 1) to :version
(default the latest).