Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Database Migration Support for SurrealDB #32

Open
gedw99 opened this issue Apr 17, 2024 · 6 comments
Open

Add Database Migration Support for SurrealDB #32

gedw99 opened this issue Apr 17, 2024 · 6 comments

Comments

@gedw99
Copy link

gedw99 commented Apr 17, 2024

What is the issue?

Currently, our project does not have a mechanism for managing database migrations for SurrealDB. Database migrations are essential for versioning and tracking changes to the database schema over time. As our project evolves, we need a way to apply schema changes consistently across different environments (development, staging, production) without manually executing SQL statements.

How can you resolve it step-by-step?

  1. Evaluate Migration Libraries: We have two options to consider:

  2. Choose a Migration Library: After evaluating the features, documentation, and community support of both libraries, decide which one better suits our project's needs.

  3. Install the Migration Library: Follow the installation instructions provided by the chosen library's documentation.

  4. Set up the Migration Directory: Create a dedicated directory within our project to store migration files. A common convention is to have a migrations directory at the root level.

  5. Create Initial Migration: Generate the initial migration file that represents the current state of the database schema. This migration file should be named with a descriptive prefix and a timestamp (e.g., 001_initial_schema.surreal).

  6. Write Migration Files: As we make changes to the database schema, create new migration files with descriptive names and timestamps (e.g., 002_add_user_table.surreal, 003_create_index_on_users.surreal). These files should contain the SQL statements necessary to apply or revert the schema changes.

  7. Integrate Migration Commands: Depending on the chosen migration library, integrate the necessary commands or scripts into our project's build process or deployment pipeline. This could involve running migration commands during application startup, deployment, or through dedicated scripts.

  8. Document Migration Process: Update our project's documentation to include instructions on how to run migrations, create new migrations, and manage the migration history.

  9. Test Migrations: Set up a testing environment and ensure that migrations can be applied and reverted successfully without any issues.

  10. Commit and Push Changes: Once everything is working as expected, commit the changes to version control and push them to the remote repository.

References/Links

By following these steps, we can introduce database migration support for SurrealDB in our project, ensuring a consistent and maintainable approach to managing schema changes across different environments.

@sbshah97
Copy link
Owner

sbshah97 commented May 7, 2024

Hi, sorry what is it that you are looking to do ?

@gedw99
Copy link
Author

gedw99 commented May 8, 2024

sorry for not adding context.

I was think that we could setup this starter project to also include the migrations using that https://github.com/Odonno/surrealdb-migrations

there is also a pure golang migrations project for surreal DB that we could also look at: https://github.com/JohnKinyanjui/surrealgo_migrate.

It already has example setup of it at : https://github.com/JohnKinyanjui/surrealgo_migrate/tree/main/examples/database/migrations

Let me know what you think and we can work on it together if you wish.

@sbshah97
Copy link
Owner

This looks interesting and promising. Do you want to put out a MR?

@sbshah97 sbshah97 changed the title migrations Add Database Migration Support for SurrealDB May 12, 2024
@sbshah97
Copy link
Owner

Hi, I've updated the description by a bit, hopefully that helps.

@gedw99
Copy link
Author

gedw99 commented May 13, 2024

Yes it’s much better .

@gedw99
Copy link
Author

gedw99 commented May 13, 2024

This looks interesting and promising. Do you want to put out a MR?

Would like to but right now am chockers with work , so I added it so others could also pick it up

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

No branches or pull requests

2 participants