Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ModuleName
- {
- public class Migrations : DataMigrationImpl
- {
- public int Create()
- {
- return 1;
- }
- public int UpdateFrom1()
- {
- return ExecuteUpdateFrom(1);
- }
- public int UpdateFrom2()
- {
- return ExecuteUpdateFrom(2);
- }
- /// <summary>
- /// Execute the update migration step.
- /// </summary>
- /// <param name="updateFrom">Current migration step.</param>
- /// <param name="nextVersion">Next migration step. Specify null if the next step is the increment of 'updateFrom'.</param>
- /// <returns>The next migration step.</returns>
- private int ExecuteUpdateFrom(int updateFrom, int? nextVersion = null)
- {
- SomeRecord.UpdateFrom(updateFrom, SchemaBuilder, ContentDefinitionManager);
- return nextVersion ?? (updateFrom + 1);
- }
- }
- }
- public class SomeRecord : AbstractRecord
- {
- public virtual int Id { get; set; }
- /// <summary>
- /// Perform migration.
- /// </summary>
- /// <param name="curVersion">Version to upgrade from.</param>
- /// <param name="schemaBuilder">Schema builder.</param>
- /// <param name="contentDefinitionManager">Content definition manager.</param>
- internal static void UpdateFrom(int curVersion, SchemaBuilder schemaBuilder, IContentDefinitionManager contentDefinitionManager)
- {
- switch (curVersion)
- {
- case 1:
- {
- schemaBuilder.CreateTable(typeof(SomeRecord).Name, table => table
- .IndexColumn()
- );
- break;
- }
- case 2:
- {
- // Do nothing.. case isn't really needed either
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement