1.x
to 2.x
The 2.0.0
release of SurrealDB includes many new features, improvements, and bug fixes. However, due to this there are some breaking changes that you should be aware of when upgrading.
This guide will help you upgrade your current SurrealDB installation to the latest 2.x
release.
UPDATE
statement no longer creates records if these are missing. Instead, use the new UPSERT statement for this behaviour.file://
connection protocol has been deprecated in favour of the more explicit rocksdb://
protocol.DEFINE SCOPE
statement has been dropped in favor for the new DEFINE ACCESS TYPE RECORD
statementDEFINE TOKEN
definitions defined under scopes are now integrated into DEFINE ACCESS TYPE RECORD
.meta::tb()
-> record::tb()
meta::id()
-> record::id()
string::endsWith()
-> string::ends_with()
string::startsWith()
-> string::starts_with()
--auth
. The --unauthenticated
flag is now required in order to provide the previous default behavior.--auth-level
flag in the CLI or the surreal-auth-ns
and surreal-auth-db
headers in the HTTP REST API.--bind
command line argument.INFO
statements. The values of the secrets will appear as [REDACTED]
to prevent accidental leakage. The export functionality will still print the values of the secrets. An UNREDACTED
clause will be added soon to provide the previous behavior.surreal-
prefix. For example, the legacy ns
and db
headers are now surreal-ns
and surreal-db
.A new surreal fix
command has been implemented to automatically change the format of your stored data. The command is followed by a path to the data. For example:
# For SurrealKV surreal fix surrealkv://mydata # For RocksDB surreal fix rocksdb:somedatabase
Although the surreal fix
command is a quick way to migrate your data, it is not without its drawbacks:
If you have used the now deprecated DEFINE TOKEN
command to define a token on a Scope with the also deprecated DEFINE SCOPE
command, you will have to update your access management rules to use the new DEFINE ACCESS
which supports creating permissions using TYPE JWT and TYPE RECORD rules.
If you were querying SurrealDB via the HTTP API, the surreal fix
command will not update the header format for you. You will need to manually update the header format from ns
and db
to surreal-ns
and surreal-db
respectively before using the surreal fix
command. Learn more about this in the HTTP documentation.
The surreal fix
command above has been created specifically for 1.x instances. However, data currently on a 2.0.0-alpha
instance can still be manually exported and then reimported into a project running on 2.0.0
via the following steps.
.surql
(SurrealQL) file. You can do this using the surreal export
command in the terminal:# Example export command to export data to a file called `export.surql` in the downloads directory. surreal export --conn http://localhost:8000 --user root --pass root --ns test --db test downloads/export.surql
This will create a file called export.surql
in the current directory.
You can now import this file back into your project running on 2.0.0
.
surreal import --conn http://localhost:8000 --user root --pass root --ns test --db test downloads/export.surql
2.x
instance.If you are trying to connect to a 2.x
instance, and get an error similar to the following, you are likely using an older version of SurrealDB.
error: Storage version is out-of-date.
There have been major improvements to SurrealDB in 2.0.0
release both in alpha and beta. Check out the changes on the release page.