Пример #1
0
        private async Task RunBeforeMigration(IDbMigration migration, DatabaseVersionModel databaseVersion)
        {
            // Check Actual DatabaseVersion against the migration version
            // Don't run unless this Migrations BeforeMigration has not been run
            if (databaseVersion.IsBeforeMigrationComplete == false)
            {
                // Before Migrate

                await migration.RunOrderedMigration(MigrationStep.Setup, _dbProvider).ConfigureAwait(false);

                if (_systemRole == SystemRole.Server)
                {
                    await migration.RunOrderedMigration(MigrationStep.ServerSetup, _dbProvider).ConfigureAwait(false);
                }
                if (_systemRole == SystemRole.Client)
                {
                    await migration.RunOrderedMigration(MigrationStep.ClientSetup, _dbProvider).ConfigureAwait(false);
                }

                // Update the database version to show the before migration has been run
                databaseVersion.IsBeforeMigrationComplete = true;
                await _dbProvider.Query <DatabaseVersionModel>()
                .Where(dbv => dbv.VersionNumber == migration.MigrationVersion)
                .Update(databaseVersion)
                .ConfigureAwait(false);
            }
        }
Пример #2
0
        private async Task RunMigration(IDbMigration migration, DatabaseVersionModel databaseVersion)
        {
            // Check Actual DatabaseVersion against the migration version
            // Don't run unless this Migrations Migration has not been run
            if (databaseVersion.IsMigrationComplete == false)
            {
                await migration.RunOrderedMigration(MigrationStep.Migrate, _dbProvider).ConfigureAwait(false);

                switch (_systemRole)
                {
                case SystemRole.Server:
                    await migration.RunOrderedMigration(MigrationStep.ServerMigrate, _dbProvider).ConfigureAwait(false);

                    break;

                case SystemRole.Client:
                    await migration.RunOrderedMigration(MigrationStep.ClientMigrate, _dbProvider).ConfigureAwait(false);

                    break;
                }

                // Update the database version to show the migration has been run
                databaseVersion.IsMigrationComplete = true;
                await _dbProvider.Query <DatabaseVersionModel>()
                .Where(dbv => dbv.VersionNumber == migration.MigrationVersion)
                .Update(databaseVersion)
                .ConfigureAwait(false);
            }
        }