Closed turbohz closed 9 months ago
This mode is still not well documented, here's an explanation:
https://surrealdb.com/docs/cli/start
SurrealDB supports the ability to startup in strict mode. When running in strict mode, all NAMESPACE, DATABASE, and TABLE definitions will not be created automatically when data is inserted. Instead, if the selected namespace, database, or table has not been specifically defined, then the query will return an error.
user@localhost % surreal start --strict --log debug memory
Hi @turbohz
Thank you for your feedback. I can indeed reproduce this error.
This error is happening because in order to apply migrations, we have first to detect the already applied migrations. Hence the table must be created or it returns []
when the table does not exist. But in strict mode, it seems you cannot query something that does not exist.
The simple fix would be to detect the absence of this table using INFO FOR DB;
. If the table does not exist, we can skip retrieving the list of migrations.
Cool. I might try to implement a fix.
Here is some tasks to get you on track:
--strict
option in https://github.com/Odonno/surrealdb-migrations/blob/main/before-integration-tests.shINFO FOR DB;
query to detect presence of the table script_migration
, here should be the right place: https://github.com/Odonno/surrealdb-migrations/blob/main/src/surrealdb.rs#L95Good luck!
Describe the bug
The tool does not work when running a SurrealDB instance with
SURREAL_STRICT=true
.To Reproduce
SURREAL_STRICT=true
.surrealdb-migrations scaffold template empty
surrealdb-migrations apply
Initially, you’ll get:
If you create the namespace and database already defined in the config file, then you get:
Expected behavior
Successful creation of the
script_migration
table.Perhaps, even, the namespace and database specified in the configuration file (debatable).
Information