private void run_changes(Migrate migrator, ConfigurationPropertyHolder configuration, Assembly migrations_assembly)
        {
            var files_directory = configuration.SqlFilesDirectory;

            configuration.SqlFilesDirectory = ".";
            bool restoring_the_database = RefreshDatabaseParameters.RestoreDatabase;
            var  initial_development    = RefreshDatabaseParameters.DropDatabaseFirst;

            if (initial_development)
            {
                migrator.RunDropCreate();
            }
            else if (restoring_the_database)
            {
                configuration.Restore = true;
                migrator.RunRestore();
            }
            else
            {
                migrator.Run();
            }

            generate_database_changes(migrations_assembly);
            Console.WriteLine("NOTE: To regenerate files you need to first delete them from the file system.");

            configuration.SqlFilesDirectory = files_directory;
            configuration.Restore           = false;
            migrator.Run();
        }
Exemplo n.º 2
0
        public void TestMigrate()
        {
            string storageFolder = Factory.Settings["AppDataFolder"];

            if (storageFolder == null)
            {
                throw new ApplicationException("Must set AppDataFolder property in app.config");
            }
            string origFile   = storageFolder + @"\Test\\DataCache\USDJPY.Migrate.tck";
            string tempFile   = origFile + ".temp";
            string backupFile = origFile + ".back";

            File.Delete(backupFile);
            File.Delete(origFile);
            string fileName = storageFolder + @"\Test\\DataCache\USD_JPY.tck";

            if (!File.Exists(fileName))
            {
                fileName = fileName.Replace(".tck", "_Tick.tck");
            }
            File.Copy(fileName, origFile);

            string[] args = { origFile };

            Migrate migrate = new Migrate();

            migrate.Run(args);
            Assert.IsTrue(File.Exists(origFile));
            Assert.IsTrue(File.Exists(backupFile));
            Assert.IsFalse(File.Exists(tempFile));
        }
Exemplo n.º 3
0
 public override void Context()
 {
     lock (server_name)
     {
         migrator = new Migrate().Set(p =>
         {
             p.ServerName        = server_name;
             p.Logger            = new ConsoleLogger();
             p.DatabaseType      = "SqlServerCE";
             p.SqlFilesDirectory = sql_files_folder;
             p.Silent            = true;
         });
         migrator.Run();
     }
 }
Exemplo n.º 4
0
        public void Deploy(string schemaScriptsFolder, string repository = "", bool dropDatabase = false)
        {
            if (schemaScriptsFolder == string.Empty)
            {
                schemaScriptsFolder = Assembly.GetExecutingAssembly().Directory();
            }

            if (!Directory.Exists(schemaScriptsFolder))
            {
                throw new DirectoryNotFoundException(
                          string.Format(
                              "Database schema scripts folder {0}\r\ndoes not exist", schemaScriptsFolder));
            }

            var roundhouseMigrate = new Migrate();

            if (DatabaseFolderStructure != null)
            {
                DatabaseFolderStructure.SetMigrateFolders(roundhouseMigrate, schemaScriptsFolder);
            }
            if (databaseRestoreOptions != null)
            {
                databaseRestoreOptions.SetRunRestoreOptions(roundhouseMigrate);
            }

            roundhouseMigrate.Set(x => x.ConnectionString = this.ConnectionString)
            .Set(x => x.SqlFilesDirectory          = schemaScriptsFolder)
            .Set(x => x.VersionFile                = Path.Combine(schemaScriptsFolder, "_BuildInfo.txt"))
            .Set(x => x.WithTransaction            = WithTransaction)
            .Set(x => x.Silent                     = true)
            .Set(x => x.RecoveryMode               = RecoveryMode.NoChange)
            .Set(x => x.RepositoryPath             = repository)
            .Set(x => x.WarnOnOneTimeScriptChanges = WarnOnOneTimeScriptChanges)
            .Set(x => x.DisableTokenReplacement    = true)
            .Set(x => x.Drop = dropDatabase)
            .SetCustomLogging(logger);

            if (databaseRestoreOptions != null)
            {
                roundhouseMigrate.RunRestore();
            }
            else
            {
                roundhouseMigrate.Run();
            }
        }
Exemplo n.º 5
0
        protected override void main(string[] args)
        {
            if (0 == args.Length)
            {
                System.Console.WriteLine("Press 'C' to clean, any other key runs migration.");
                if (ConsoleKey.C == System.Console.ReadKey().Key)
                {
                    args = new string[] { "clean" }
                }
                ;
            }
            Migrate migrate = new Migrate(new ContactsMigration.CConsole());

            migrate.Run(Program.DefaultConnectionString, args.Length > 0 ? args[0] : null);
            System.Console.WriteLine("Press any key...");
            System.Console.ReadKey();
        }
    }
Exemplo n.º 6
0
 static int RunMigrate(ILogger logger, MigrateOptions options) => Migrate.Run(logger);
Exemplo n.º 7
0
 static int RunMigrate(MigrateOptions opts) =>
 Migrate.Run();
 public static void Main()
 {
     // Make an instance of the player, and let it play the gaqme.
     Migrate migrate = new Migrate();
     migrate.Run();
 }