DIALECT_NOT_STATED
A command that reads no database could not tell which one its migrations are for: no `--dialect`, no migration file naming one, and no `DB_DIALECT` or `DATABASE_URL`.
Cause
A command that reads no database could not tell which one its migrations are for: no --dialect, no migration file naming one, and no DB_DIALECT or DATABASE_URL.
nextly migrate:check and nextly migrate:create compare the configuration with the migrations folder, which needs no database, so they run without DATABASE_URL. They still need to know which database the migrations are for, since each dialect writes its own SQL. They take it from, in order:
--dialect;- the newest migration that says: one written as a single dialect's file (
0003_seed.sqlite.sql) by its name, any other by the dialect its header names (-- Dialect: PostgreSQL); DB_DIALECT, else the scheme ofDATABASE_URL, read without connecting;- a question, when the command runs at a terminal.
When none of these says, and no terminal is attached to ask, as in CI before the first migration, the command refuses.
Fix
- Pass
--dialectwithpostgresql,mysqlorsqlite, or setDB_DIALECT. - Once the first migration is written, its header names the dialect and the flag is no longer needed.
Example
✗ The command could not tell which database the migrations are for.
Why: It reads no database, no migration file names its dialect yet, and neither `DB_DIALECT` nor `DATABASE_URL` is set.
Next: Pass `--dialect` with `postgresql`, `mysql` or `sqlite`, or set `DB_DIALECT`.
Docs: https://nextlyhq.com/docs/cli/errors/dialect-not-stated (DIALECT_NOT_STATED)