It's possible to write custom queries to be executed during migrations using Plugins.
Currently a plugin can only declare tap on the Writer system, with the
The arguments are:
operation: string, can be one of the following:
type: 'before' | 'after'
callback: functionwhich get those parameters:
Then, instantiate the plugin in the
plugins option array of the
For example, let's say we have the following schema:
Now we want to migrate the
user table from two columns
lname into one:
Here is the example code to achieve this:
The above code does the following:
- Remove the
fnamefield from the schema.
fullnamein the schema.
- Annotate the
fullnamefield to indicate it's the new name of
- We declare a plugin that tap into the
- In this hook, we read the users and update each one of them to merge the two columns into
fnamecolumn is dropped.