In the previous article, we mentioned migrations, which is a little derivative.
1: What is migrations?
Orchard provides the module upgrade function, that is, if we need to upgrade the module after it is released, we can implement it through encoding;
2: Migrations format
Public class migrations: datamigrationimpl
{
Public int create ()
{
Return 1;
}
Public int updatefrom1 ()
{
// Code to be executed
Return 2;
}
}
Note that every upgrade is a different method. The next upgrade is:
Public int updatefrom2 ()
{
Return 3;
}
3: Where is the returned value stored?
In the [orchard_framework_datamigrationrecord] Table, the version field is. If you do not know the version to update, check it.
4: Update prompt
As mentioned in the official documentation, every time after migrations, If we exit and log on to the background, an update prompt will be displayed. This seems to be a small problem. In fact, you may not see this update prompt, and you may encounter the same results as me:
* Restart the application and see the update;
* Update is not actually seen, but the code in the updatefrom n method in migrations is indeed executed.
So, how can we determine whether the code is actually executed? Return to step 2 to check whether the version in the database has been updated. If yes, it is.