migrations

package
v1.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package migrations — commerce-owned base migrations.

Each file registers an up/down migration via core.AppMigrations. They run after base's SystemMigrations and before the app starts serving, on every store.New() call. Naming convention is `<unix_ts>_<snake_name>.go` to give a deterministic apply order.

Package migrations — commerce-owned base migrations.

1735000001_create_tenant_hostnames pulls hostnames out of the commerce_tenants.hostnames JSON column into a separate row-per-hostname collection so a UNIQUE index can enforce global claim ownership.

Why a join table rather than a JSON-column-level index:

  • SQLite's generated-column + UNIQUE INDEX over JSON arrays is expressible (via `json_each`) but the syntax does not translate 1:1 to Postgres's expression index, so keeping parity across backends via a first-class relation table is simpler and race-safer across replicas.
  • A row-per-hostname lets the unique constraint land at the SQL engine, which is the only place that can survive concurrent transactions from distinct commerce replicas. Application-level mutex checks race.

This migration runs AFTER 1735000000_create_tenants so the relation field can reference the commerce_tenants collection by its canonical id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL