Skip to content

Allow importing data when the SurrealDB server starts#5120

Merged
tobiemh merged 2 commits into
mainfrom
gerard/start-import-file
Nov 15, 2024
Merged

Allow importing data when the SurrealDB server starts#5120
tobiemh merged 2 commits into
mainfrom
gerard/start-import-file

Conversation

@geraname

@geraname geraname commented Nov 15, 2024

Copy link
Copy Markdown
Contributor

Thank you for submitting this pull request. We really appreciate you spending the time to work on SurrealDB. 🚀 🎉

What is the motivation?

To address uses cases that require that certain resources exist in the datastore when the server is started.

What does this change do?

This feature will import a file containing SurrealQL queries to the datastore with owner permissions on ROOT before the server is started. This feature functions similarly to the import sub-command. While the flag is present, the file will be imported every time that the server is started; this allows creating users, access methods and any other resources or data that clients may need to rely on. An informational message is logged on the server whenever data is imported from a file on start.

From a security perspective, this feature is used when starting the server and hence already requires complete access to the datastore, which is extended to the import file. On the other hand, this feature provides an alternative to the -u and -p flags that would create a root-level owner user when starting the server for the first time, allowing users to instead rely on more secure paswordless access methods, which can also be kept updated when restarting the server.

What is your testing strategy?

Implement integration tests for the basic import functionality, the effect on a restart in any imported resources, the creation of resources at different levels and the requirement of providing an existent file.

Is this related to any issues?

No.

Does this change need documentation?

Yes, this requires updating the CLI documentation for the start command.

Have you read the Contributing Guidelines?

@geraname geraname marked this pull request as ready for review November 15, 2024 12:58
@geraname geraname requested review from a team and tobiemh as code owners November 15, 2024 12:58
@geraname geraname added the needs-documentation Needs documentation to be added and tracked before merge label Nov 15, 2024
@tobiemh tobiemh enabled auto-merge November 15, 2024 16:11
@tobiemh tobiemh added this pull request to the merge queue Nov 15, 2024
Merged via the queue into main with commit d82f6aa Nov 15, 2024
@tobiemh tobiemh deleted the gerard/start-import-file branch November 15, 2024 16:26
@rushmorem rushmorem added this to the v2.1.0 milestone Nov 21, 2024
@Dhghomon Dhghomon removed the needs-documentation Needs documentation to be added and tracked before merge label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants