Ejemplo n.º 1
0
        protected override void ProcessRecord()
        {
            if (string.IsNullOrEmpty(Language))
                Language = "CSharp";

            if (string.IsNullOrEmpty(Provider))
                Provider = "SqlServer";

            try
            {
                var newUserAndLogin = new NewUserAndLogin(new TaskLogger(this), Provider, UserName, Password);

                if (!string.IsNullOrEmpty(this.Directory))
                {
                    ScriptEngine engine = new ScriptEngine(this.Language, null);
                    newUserAndLogin.Execute(engine.Compile(this.Directory));
                }
                if (null != this.MigrationsAssemblyPath)
                {
                    Assembly asm = Assembly.LoadFrom(this.MigrationsAssemblyPath);
                    newUserAndLogin.Execute(asm);
                }
            }
            catch (Exception e)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        e,
                        "New-DatabaseUserAndLogin",
                        ErrorCategory.NotSpecified,
                        this
                        )
                    );
            }
        }
Ejemplo n.º 2
0
        public void CanCompileAssemblies() 
        {
            var engine = new ScriptEngine();

            // This should let it work on windows or mono/unix I hope
            string dataPath = Path.Combine(Path.Combine("..", Path.Combine("src", "Migrator.Tests")), "Data");

            Assembly asm = engine.Compile(dataPath);
            Assert.IsNotNull(asm);

            var loader = new MigrationLoader(null, asm, false, null);
            Assert.AreEqual(2, loader.LastVersion);

            Assert.AreEqual(2, loader.GetMigrationTypes(asm, null).Count);
        }
Ejemplo n.º 3
0
		protected override void ExecuteTask()
		{
			if (! String.IsNullOrEmpty(Directory))
			{
				var engine = new ScriptEngine(Language, null);
				Execute(engine.Compile(Directory));
			}

			if (null != MigrationsAssembly)
			{
				Assembly asm = Assembly.LoadFrom(MigrationsAssembly.FullName);
				Execute(asm);
			}
		}
Ejemplo n.º 4
0
		public override bool Execute()
		{
            if (! String.IsNullOrEmpty(Directory))
            {
                ScriptEngine engine = new ScriptEngine(Language, null);
                Execute(engine.Compile(Directory));
            }

            if (null != Migrations)
            {
                foreach (ITaskItem assembly in Migrations)
                {
                    Assembly asm = Assembly.LoadFrom(assembly.GetMetadata("FullPath"));
                    Execute(asm);
                }
            }

		    return true;
		}
Ejemplo n.º 5
0
        protected override void ProcessRecord()
        {
            if (string.IsNullOrEmpty(Language))
                Language = "CSharp";

            if (string.IsNullOrEmpty(Provider))
                Provider = "SqlServer";

            try
            {
                DatabaseMigrator db = new DatabaseMigrator(new TaskLogger(this), DryRun, Provider, VersionTo, Trace);

                if (!string.IsNullOrEmpty(this.Directory))
                {
                    ScriptEngine engine = new ScriptEngine(this.Language, null);
                    db.Execute(engine.Compile(this.Directory));
                }
                if (null != this.MigrationsAssemblyPath)
                {
                    Assembly asm = Assembly.LoadFrom(this.MigrationsAssemblyPath);
                    db.Execute(asm);
                }
            }
            catch (Exception e)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        e,
                        "Push-DatabaseMigrations",
                        ErrorCategory.NotSpecified,
                        this
                        )
                    );
            }
        }