authtempo generate
For: a developer whose app reads the authtempo tables through an ORM, or who reviews the tables before the first migration.
What it does: this page lists the three formats of authtempo generate, its flags, its JSON document, and what the output never holds.
Before you start
Section titled “Before you start”- The CLI, built from this repo. Run it from this repo tells how.
- The tables stay the tables of authtempo. Create and change them with authtempo migrate.
The command
Section titled “The command”The @authtempo packages are on npm. Add the CLI to your app with pnpm add -D @authtempo/cli, and run each command as pnpm exec authtempo ….
authtempo generate --format sql --dialect postgresauthtempo generate --format drizzle --dialect sqlite --out src/authtempo-schema.tsauthtempo generate --format prisma --dialect mysql| Flag | What it does |
|---|---|
--format sql, --format drizzle, --format prisma |
The form of the output. It has no default. |
--dialect sqlite, --dialect postgres, --dialect mysql |
The database of the output. It has no default. A D1 app applies the files of @authtempo/adapter-d1 with wrangler. |
--out <file> |
Writes the output to a new file. The command writes no file over a file or a link. |
--json |
Prints the document of The JSON. exit: the exit code of the run. stopped: the reason of a stop or a usage error, or null. |
-h, --help |
Prints the complete help. The command ignores every other argument. |
| Exit code | What it means |
|---|---|
| 0 | The output is printed or written. |
| 2 | A usage error, or the file of –out exists. |
--dialect d1 is a usage error. It names --dialect sqlite, because D1 runs the SQLite dialect.
The three formats
Section titled “The three formats”Each output starts with one header line. The line holds the schema version, the dialect, the CLI version, and the rule: authtempo owns these tables. Write rows through the engine only. The output is for reads: a write through the ORM skips the guards of the engine.
- SQL. The statements that make each table, key, and index on an empty database, then the records of the migration runner. After the apply,
authtempo migratefinds nothing to do. The shape suite of each adapter proves that these statements and the shipped migrations make the same database. - Drizzle. One table per model, such as
taUser, with the table, column, key, and index names of the database. A date reads as aDate, a boolean as a boolean, and JSON as an object. Keep the file out of the schema glob ofdrizzle.config.ts. SettablesFilterto the tables of the app, sodrizzle-kit pushleaves the authtempo tables alone. - Prisma. One model per table, such as
TaUser, with@@map,@map, and the names of each key and index. The header gives theprisma.config.tskeys of externally managed tables, a Preview feature of Prisma 7.10. On SQLite and MySQL, a date is aBigIntof epoch milliseconds. On SQLite, JSON is aString.
The Drizzle and Prisma files mark each column that holds a sealed value or a hash, such as totp.secret or session.tokenHash.
The JSON
Section titled “The JSON”| Key | What it holds |
|---|---|
format |
The format of the run: sql, drizzle, or prisma. |
dialect |
The dialect of the run: sqlite, postgres, or mysql. |
schemaVersion |
The schema version of the core that the CLI bundles. |
out |
The path of the file that --out wrote, or null. |
text |
The output, or null when --out wrote it to a file. |
exit |
The exit code of the run. |
stopped |
The reason of a stop or a usage error, or null. |
The document of a stop or a usage error holds the empty values of each key, exit: 2, and the reason in stopped. The output gives the rule for every command.
What the output never holds
Section titled “What the output never holds”- No value of a variable. The command reads no environment variable.
- No host, user, or password. The command opens no connection.
- No row of a database. The output holds the shape of the tables only.