Exemple #1
0
        public override bool Execute()
        {
            if (string.IsNullOrEmpty(databaseType))
            {
                Log.LogError("You must specific a database type. i.e. mysql or sqlserver");
                return false;
            }

            if (string.IsNullOrEmpty(migrationAssembly))
            {
                Log.LogError("You must specific a migration assembly");
                return false;
            }

            Log.LogCommandLine(MessageImportance.Low, "Creating Context");
            var announcer = new BaseAnnouncer(msg => Log.LogCommandLine(MessageImportance.Normal, msg))
            {
                ShowElapsedTime = Verbose,
                ShowSql = Verbose
            };
            var runnerContext = new RunnerContext(announcer)
            {
                Database = databaseType,
                Connection = Connection,
                Target = Target,
                PreviewOnly = false,
                Namespace = Namespace,
                Task = Task,
                Version = Version,
                Steps = Steps,
                WorkingDirectory = WorkingDirectory,
                Profile = Profile,
                Timeout = Timeout
            };

            Log.LogCommandLine(MessageImportance.Low, "Executing Migration Runner");
            try
            {
                new TaskExecutor(runnerContext).Execute();
            }
            catch (ProcessorFactoryNotFoundException ex)
            {
                announcer.Error("While executing migrations the following error was encountered: {0}", ex.Message);
                return false;
            }
            catch (Exception ex)
            {
                announcer.Error("While executing migrations the following error was encountered: {0}, {1}", ex.Message, ex.StackTrace);
                return false;
            }

            return true;
        }
        public override bool Execute()
        {
            Log.LogCommandLine(MessageImportance.Low, "Creating Context");
            var announcer = new BaseAnnouncer(msg => Log.LogCommandLine(MessageImportance.Normal, msg))
                                {
                                    ShowElapsedTime = Verbose,
                                    ShowSql = Verbose
                                };
            var runnerContext = new RunnerContext(announcer)
                                    {
                                        Database = Database,
                                        Connection = Connection,
                                        Target = Target,
                                        PreviewOnly = false,
                                        Namespace = Namespace,
                                        Task = Task,
                                        Version = Version,
                                        Steps = Steps,
                                        WorkingDirectory = WorkingDirectory,
                                        AutoReverse = AutoReverse
                                    };

            Log.LogCommandLine(MessageImportance.Low, "Executing Migration Runner");
            new TaskExecutor(runnerContext).Execute();

            return true;
        }