示例#1
0
        public void Build(string path)
        {
            SchemaHelpers.EnsureSchemaInfoTable();
            FileInfo[] files = GetAllMigrationFiles(path);

            foreach (var file in files)
            {
                var fileName = file.Name;
                Console.WriteLine("Building: " + fileName);
                var migration = new SqlMigration(file.FullName, file.Name);
                migration.Execute();
            }
        }
示例#2
0
        public void Migrate()
        {
            SchemaHelpers.EnsureSchemaInfoTable();
            var versions = SchemaHelpers.GetVerionNumbers();
            var currentVersion = versions.Count > 0 ? versions.Max() : 0;
            FileInfo[] files = GetSortedMigrationFiles();

            foreach (var file in files)
            {
                var fileName = file.Name;
                var version = Int32.Parse(fileName.Substring(0, fileName.IndexOf('_')));
                if (currentVersion >= version)
                    continue;
                Console.WriteLine("Applying Migration: " + fileName);
                var migration = new SqlMigration(file.FullName, file.Name);
                migration.Execute();
                SchemaHelpers.InsertVersion(version, fileName);
                Console.WriteLine("Applied, schema is at version: " + version.ToString() + "\n");
            }
        }