示例#1
0
        public bool Execute()
        {
            try
            {
                var deployer = new DbDeployer();
                deployer.Execute(this.config, Console.Out);

                return(true);
            }
            catch (UsageException ex)
            {
                Console.Error.WriteLine(ex.Message);

                this.PrintUsage();
            }
            catch (DbDeployException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Failed to apply changes: " + ex.Message);
                Console.Error.WriteLine("Stack Trace:");
                Console.Error.Write(ex.StackTrace);
            }

            return(false);
        }
示例#2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (string.IsNullOrEmpty(this.OutputFile))
            {
                this.WriteError(new ErrorRecord(new PSInvalidOperationException(
                                                    "Missing a file for output"),
                                                "NoOutputFile",
                                                ErrorCategory.MetadataError,
                                                null));

                return;
            }

            var dbDeploy = new DbDeployer
            {
                InfoWriter         = new LambdaTextWriter(WriteVerbose),
                Dbms               = this.DatabaseType,
                ConnectionString   = this.ConnectionString,
                ChangeLogTableName = this.TableName,
                ScriptDirectory    = new DirectoryInfo(this.deltasDirectory),
            };

            dbDeploy.OutputFile = new FileInfo(this.ToAbsolutePath(OutputFile));

            if (!string.IsNullOrEmpty(this.UndoOutputFile))
            {
                dbDeploy.OutputFile = new FileInfo(this.ToAbsolutePath(UndoOutputFile));
            }

            dbDeploy.Go();
        }
示例#3
0
        private void DatabaseUpdateCheck(string connectionStringArg)
        {
            var dbDeployer = new DbDeployer(connectionStringArg);
            var isSuccess  = dbDeployer.Deploy();

            if (!isSuccess)
            {
                throw new Exception("Database update check failed.");
            }
        }
示例#4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var dbDeploy = new DbDeployer
            {
                InfoWriter         = new LambdaTextWriter(WriteVerbose),
                Dbms               = DatabaseType,
                ConnectionString   = ConnectionString,
                ChangeLogTableName = TableName,
                ScriptDirectory    = new DirectoryInfo(deltasDirectory),
            };

            dbDeploy.Go();
        }
示例#5
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var config = new DbDeployConfig
            {
                Dbms               = DatabaseType,
                ConnectionString   = ConnectionString,
                ChangeLogTableName = TableName,
                ScriptDirectory    = Parser.ParseDirectory(deltasDirectory),
            };

            var deployer = new DbDeployer();

            deployer.Execute(config, new LambdaTextWriter(WriteVerbose));
        }
示例#6
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (string.IsNullOrEmpty(this.OutputFile))
            {
                this.WriteError(new ErrorRecord(new PSInvalidOperationException(
                                                    "Missing a file for output"),
                                                "NoOutputFile",
                                                ErrorCategory.MetadataError,
                                                null));

                return;
            }

            var config = new DbDeployConfig
            {
                Dbms                     = this.DatabaseType,
                ConnectionString         = this.ConnectionString,
                ChangeLogTableName       = this.TableName,
                ScriptDirectory          = new DirectoryInfo(this.deltasDirectory),
                AutoCreateChangeLogTable = this.AutoCreateChangeLogTable,
                ForceUpdate              = this.ForceUpdate,
                UseSqlCmd                = this.UseSqlCmd,
                OutputFile               = new FileInfo(this.ToAbsolutePath(this.OutputFile))
            };

            if (!string.IsNullOrEmpty(this.UndoOutputFile))
            {
                config.OutputFile = new FileInfo(this.ToAbsolutePath(UndoOutputFile));
            }

            var deployer = new DbDeployer();

            deployer.Execute(config, new LambdaTextWriter(WriteVerbose));
        }
示例#7
0
        public static void AutoDeployDatabase(DbDeployer.InstallEventHandler onProcess, IEnumerable<string> tablePrefixs)
        {
            Stream dbStream = new MemoryStream(Encoding.UTF8.GetBytes(Install_Bin.scheme_xml));
            string errorLog;
            DbDeployer.Update(Settings.Current.IConnectionString, dbStream, onProcess, tablePrefixs, out errorLog);
            if (!string.IsNullOrEmpty(errorLog))
                CreateLog(errorLog);

            UpdateVersion(Settings.Versions[Settings.Versions.Length - 1]);
        }
示例#8
0
        public Dbdeploy()
        {
            this.dbDeploy = new DbDeployer();

            this.dbDeploy.InfoWriter = Console.Out;
        }
示例#9
0
 public static void ClassInitialize(TestContext testContext)
 {
     DbDeployer.StartLocalDb(LocalDbInstance, testContext, typeof(ExampleDomainContext));
     InitDb();
 }