Open gedw99 opened 7 months ago
Hi, sorry what is it that you are looking to do ?
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.
This looks interesting and promising. Do you want to put out a MR?
Hi, I've updated the description by a bit, hopefully that helps.
Yes it’s much better .
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
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?
Evaluate Migration Libraries: We have two options to consider:
Choose a Migration Library: After evaluating the features, documentation, and community support of both libraries, decide which one better suits our project's needs.
Install the Migration Library: Follow the installation instructions provided by the chosen library's documentation.
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.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
).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.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.
Document Migration Process: Update our project's documentation to include instructions on how to run migrations, create new migrations, and manage the migration history.
Test Migrations: Set up a testing environment and ensure that migrations can be applied and reverted successfully without any issues.
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.