You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have developed a rather small application which I did not want to use a full relational database for. Instead I went with using Redis. The service I work on stores user data and technical configuration objects. In my case this data does not often require structural changes due to changes in my applications code. But still I'd like to have the benefit of a proper migration framework such as migrate.
Therefore I want to discuss implementing support for Redis as database driver. I am in fact already experimenting with this in my local project and could post updates if there is interest in this.
Idea
The general idea is to implement the Driver interface based on a Redis API client. I currently use github.com/go-redis/redis.
Most functions defined by the interface are rather simple to implement, using 2 or 3 keys to manage the migration state (version and dirty flag) and the migration lock.
What I am currently wondering about is what the actual migrations could look like. Generally it is possible to send raw redis commands via Client.Do. This can be used to store redis commands as migration files.
For more complex use cases this may not be enough. If for example I wanted to load every key resembling some user object and then would want to change it based on some criteria, then this would require the ability to include some logic into the migrations. Maybe Lua scripting is suitable for that. I have not yet looked at this further but having a look at the mongodb driver is probably also worth a look.
What do you think? I am sure there are lots of ways to migrate data persisted in non-relational databases which I'd also like to discuss.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone!
Context
I have developed a rather small application which I did not want to use a full relational database for. Instead I went with using Redis. The service I work on stores user data and technical configuration objects. In my case this data does not often require structural changes due to changes in my applications code. But still I'd like to have the benefit of a proper migration framework such as migrate.
Therefore I want to discuss implementing support for Redis as database driver. I am in fact already experimenting with this in my local project and could post updates if there is interest in this.
Idea
The general idea is to implement the
Driver
interface based on a Redis API client. I currently usegithub.com/go-redis/redis
.migrate/database/driver.go
Line 45 in 856ea12
Most functions defined by the interface are rather simple to implement, using 2 or 3 keys to manage the migration state (version and dirty flag) and the migration lock.
What I am currently wondering about is what the actual migrations could look like. Generally it is possible to send raw redis commands via
Client.Do
. This can be used to store redis commands as migration files.For more complex use cases this may not be enough. If for example I wanted to load every key resembling some user object and then would want to change it based on some criteria, then this would require the ability to include some logic into the migrations. Maybe Lua scripting is suitable for that. I have not yet looked at this further but having a look at the
mongodb
driver is probably also worth a look.What do you think? I am sure there are lots of ways to migrate data persisted in non-relational databases which I'd also like to discuss.
Beta Was this translation helpful? Give feedback.
All reactions