diff --git a/org-templates/github-profile-README.md b/org-templates/github-profile-README.md index 84fb970..0be860e 100644 --- a/org-templates/github-profile-README.md +++ b/org-templates/github-profile-README.md @@ -7,7 +7,7 @@ ```bash git clone https://github.com/OpenSourceOM/core.git cd core && cp .env.example .env && docker compose up -d -go build -o om ./cmd/om && ./om migrate && ./om scan demo && ./om rules run +go build -o om ./cmd/om && ./om scan demo && ./om rules run open http://localhost:8080 ``` diff --git a/src/pages/docs/cli.astro b/src/pages/docs/cli.astro index 92a4675..3a0a482 100644 --- a/src/pages/docs/cli.astro +++ b/src/pages/docs/cli.astro @@ -33,11 +33,11 @@ import DocsLayout from '@/layouts/DocsLayout.astro';
om migrateom serve does this on startup unless OM_AUTO_MIGRATE=false.om serveOM_API_PORT and serve the API plus the console.OM_API_PORT and serve the API plus the console.om scan demo8080om serveOM_AUTO_MIGRATEtrueom serve applies pending migrations before it listens. Set false when om migrate should be the only schema change. om migrate itself ignores this variable.OM_ADMIN_EMAIL
- The API container does not migrate on startup. From a checkout, with the CLI on the host:
+ om serve applies pending SQL files in migrations/ before it
+ listens. Compose starts the API with that command, so docker compose up -d
+ creates the schema. A later image applies only the files that are not already recorded in
+ schema_migrations. Startup logs applied database migrations or
+ database schema is current.
{`go build -o om ./cmd/om
+
+ Set OM_AUTO_MIGRATE=false in .env when a separate step should own
+ the schema. om migrate is also how you migrate when Compose is running Postgres
+ alone:
+
+ {`docker compose up -d postgres
+go build -o om ./cmd/om
./om migrate`}
The CLI’s default database host is localhost, which is the published port.
@@ -61,14 +71,16 @@ docker compose ps`}
POSTGRES_HOST=postgres in the shell is the usual miss. That hostname exists only on the Compose network. Unset it, or set POSTGRES_HOST=localhost, for a CLI on the host.POSTGRES_PASSWORD in .env after the first start does not alter an existing volume.om migrate on the host does not. If it runs before the port is open, retry it.relation "nodes" does not exist means migrate has not been applied to this database.om migrate on the host does not wait. If it runs before the port is open, retry it.relation "nodes" does not exist means the API has not finished starting, or OM_AUTO_MIGRATE=false and om migrate has not been applied to this database.
GET http://localhost:8080/v1/health returns
- {`{"status":"ok","service":"opensourceom-api"}`} when the API process is up. It
- does not check Postgres. A scan that fails on the database while health is ok means the CLI
- and the container are not using the same connection settings.
+ {`{"status":"ok","service":"opensourceom-api"}`} when the API process is up and
+ Postgres answers a ping. om serve applies migrations before it listens, so a
+ healthy API has the current schema when OM_AUTO_MIGRATE is left on. A scan that
+ fails on the database while health is ok means the CLI and the container are not using the
+ same connection settings.
- down -v deletes the Postgres volume. The next start is an empty database and
- needs om migrate again.
+ down -v deletes the Postgres volume. The next API start is an empty database
+ and applies migrations again.
Compose publishes Postgres on localhost:5432 and the API on
- http://localhost:8080. The API container does not apply
- schema migrations. The CLI does.
+ http://localhost:8080. The API applies pending
+ migrations before it listens.
Compose reads .env for the API container. The CLI does not. It defaults to
@@ -58,12 +58,14 @@ docker compose up -d`}
export that value into the shell you use for om.
{`go build -o om ./cmd/om
-./om migrate`}
+ {`go build -o om ./cmd/om`}
- om migrate applies the SQL files in migrations/. Run it from the
- repository root so the CLI can find that directory.
+ The API container runs om serve, which applies the SQL files in
+ migrations/ before it listens. A later start applies only files that are not
+ already recorded. When Compose is running Postgres without the API, run
+ om migrate from the repository root. Set OM_AUTO_MIGRATE=false on
+ the API when that command should be the only schema change.
0.4.0. When bundled Postgres is enabled, an init container named
wait-db runs pg_isready against
{'{{release}}-opensourceom-postgres'}. A second init container runs
- om migrate. The main container runs om serve. Readiness and
- liveness probe GET /v1/health. With an external database,
+ om migrate. The main container runs om serve, which applies any
+ migrations still pending. api.autoMigrate (default true) sets
+ OM_AUTO_MIGRATE. Readiness and liveness probe GET /v1/health.
+ With an external database,
wait-db is omitted and migrate still runs, so that host must
accept connections before the pod can become Ready.
@@ -76,6 +78,11 @@ helm install om deploy/helm/opensourceom \\
productionOM_ENV.api.autoMigratetrueOM_AUTO_MIGRATE. om serve applies pending migrations. The init container still runs om migrate first.api.smtp.host / api.smtp.port / api.smtp.from587 / empty
- om migrate creates nodes and edges. Both rows carry
+ om migrate and om serve create nodes and edges. Both rows carry
properties JSONB. Edges reference nodes with ON DELETE CASCADE.
The unique key on an edge is (source_id, target_id, type).