Quick start
Start with an empty directory. You will create one desired-schema file, preview the SQL Ptah plans, apply it to a local SQLite database, and read the live schema back. The result is disposable and needs no database server, Docker, or Go toolchain.
What you need
Section titled “What you need”- A
ptahbinary on yourPATH. Install Ptah if you do not have one. - A terminal and about five minutes.
Confirm that the binary runs:
ptah versionThe output names the version and platform. Their values depend on how you installed Ptah.
Step 1. Create the working files
Section titled “Step 1. Create the working files”mkdir ptah-quick-startcd ptah-quick-startcat > schema.sql <<'SQL'CREATE TABLE users ( id INTEGER PRIMARY KEY, email TEXT NOT NULL);SQLNew-Item -ItemType Directory ptah-quick-start | Out-NullSet-Location ptah-quick-start@'CREATE TABLE users ( id INTEGER PRIMARY KEY, email TEXT NOT NULL);'@ | Set-Content schema.sqlschema.sql is the schema you want. app.db does not exist yet.
Step 2. Preview the plan
Section titled “Step 2. Preview the plan”ptah schema apply --schema-file schema.sql --db-url sqlite://app.db --dry-runExpected output on standard output:
Planned schema changes:CREATE TABLE "users" ( "id" INTEGER PRIMARY KEY, "email" TEXT NOT NULL);--dry-run opens the target to inspect its current schema but executes no
planned statement.
Step 3. Apply the plan
Section titled “Step 3. Apply the plan”ptah schema apply --schema-file schema.sql --db-url sqlite://app.db --auto-approveExpected output includes the reviewed plan, on standard output:
Planned schema changes:CREATE TABLE "users" ( "id" INTEGER PRIMARY KEY, "email" TEXT NOT NULL);Expected output also includes the completion result, on standard output:
Auto-approval enabled; applying schema changes.Schema apply completed successfully.Step 4. Verify the live database
Section titled “Step 4. Verify the live database”ptah db read --db-url sqlite://app.dbExpected output includes, on standard output:
CREATE TABLE "users" ( "id" INTEGER PRIMARY KEY, "email" TEXT NOT NULL);This output comes from app.db, not from schema.sql. The database now matches
the desired schema you reviewed.
Step 5. Clean up
Section titled “Step 5. Clean up”Leave the working directory, then remove only the directory this tutorial created.
cd ..rm -rf ptah-quick-startSet-Location ..Remove-Item -Recurse -Force ptah-quick-startNext steps
Section titled “Next steps”- Evolve the schema and add a drift gate.
- Create and apply a versioned migration.
- Choose a schema workflow before using a shared database.
- Use another schema source such as YAML, HCL, DBML, an ORM loader, or Go annotations.