#database-migrations #surrealdb #migration

bin+lib surrealdb-simple-migration

Simple yet powerful database migration tool for SurrealDB

6 releases

0.3.1 Oct 16, 2024
0.3.0 Oct 15, 2024
0.2.2 Aug 5, 2024
0.2.1 May 29, 2024
0.1.0 May 29, 2024

#1867 in Database interfaces

Download history 114/week @ 2024-08-03 6/week @ 2024-08-10 5/week @ 2024-09-14 17/week @ 2024-09-21 16/week @ 2024-09-28 277/week @ 2024-10-12 32/week @ 2024-10-19 2/week @ 2024-10-26

312 downloads per month

MIT/Apache

33KB
346 lines

surrealdb-simple-migration

A simple library for surrealdb migration process.

Usage - Library

  1. This library migrates files under the pattern <file_number>(_<filename>).surql. Here some examples:
    path_to_dir/001.surql
    path_to_dir/002_create_users_table.surql
    path_to_dir/003_drop.surql
  1. In code:
    let db_connection = ...;
    let migration_directory_path = "your/custom/path";

    // Here the code from the Library
    surrealdb_simple_migration::migrate(&db_connection, migration_directory_path).await;

Usage - Command Line Interface

Install the package using cargo install surrealdb-simple-migration. It will automatically install the binary named ssm (short for surrealdb-simple-migration). Once installed, just run the command ssm apply to apply your migrations files. (default path for the directory of your migration files: ./, default host address for you surrealdb instance http://localhost:8000).

The default namespace and database used on the surrealdb instance are default and dev.

If you want to reset your migrations use ssm reset.

CLI Configuration

You can config the CLI to use either your environment variables or pass the desired information as options.

  • SSM_HOST OR -H your_host_address in the CLI : Setup the host address (default http://localhost:8000).
  • SSM_PATH OR -p your/migration/files/path/ in the CLI : Setup the path used to run the migrations against (default to ./).
  • SSM_NAMESPACE OR -n the_database_namespace in the CLI : Setup the namespace used to run the migrations against (default to default).
  • SSM_DB_NAME OR -n the_database_namespace in the CLI : Setup the database used to run the migrations against (default to dev).

Dependencies

~73MB
~1.5M SLoC