コード例 #1
0
        public static void PerformMigrations()
        {
            int activeVersion = GetActiveVersion();

            if (activeVersion == Global.CurrentVersionInt)
            {
                return;
            }

            List <GenericMigration> plannedMigrations = new List <GenericMigration>();

            foreach (Type migrationType in GetAvailableMigrations())
            {
                GenericMigration migration = (GenericMigration)Activator.CreateInstance(migrationType);
                if (activeVersion < migration.Version)
                {
                    plannedMigrations.Add(migration);
                }
            }

            plannedMigrations.OrderBy(n => n.Version);

            foreach (GenericMigration plannedMigration in plannedMigrations)
            {
                plannedMigration.DoMigration();
            }
        }
コード例 #2
0
        public static void PerformMigrations()
        {
            Console.Write("Migration Manager is called");

            int activeVersion = GetActiveVersion();

            if (activeVersion == Global.CurrentVersionInt)
            {
                Console.Write("Migrations are not needed: version is actual");
                return;
            }

            List <GenericMigration> plannedMigrations = new List <GenericMigration>();

            foreach (Type migrationType in GetAvailableMigrations())
            {
                GenericMigration migration = (GenericMigration)Activator.CreateInstance(migrationType);
                if (activeVersion < migration.Version)
                {
                    plannedMigrations.Add(migration);
                }
            }

            plannedMigrations.OrderBy(n => n.Version);

            foreach (GenericMigration plannedMigration in plannedMigrations)
            {
                plannedMigration.DoMigration();
            }

            Console.Write("All migrations are finished");
        }