Beispiel #1
0
        protected override int Execute()
        {
            var sql = CreateExecutor().ScriptMigration(
                _from.Value,
                _to.Value,
                _idempotent.HasValue(),
                Context.Value());

            if (!_output.HasValue())
            {
                Reporter.WriteData(sql);
            }
            else
            {
                var output = _output.Value();
                if (WorkingDir.HasValue())
                {
                    output = Path.Combine(WorkingDir.Value(), output);
                }

                var directory = Path.GetDirectoryName(output);
                if (!string.IsNullOrEmpty(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                Reporter.WriteVerbose(Resources.WritingFile(_output.Value()));
                File.WriteAllText(output, sql, Encoding.UTF8);
            }

            return(base.Execute());
        }
        protected override int Execute(string[] args)
        {
            using var executor = CreateExecutor(args);
            var sql = executor.ScriptDbContext(Context.Value());

            if (!_output.HasValue())
            {
                Reporter.WriteData(sql);
            }
            else
            {
                var output = _output.Value();
                if (WorkingDir.HasValue())
                {
                    output = Path.Combine(WorkingDir.Value(), output);
                }

                var directory = Path.GetDirectoryName(output);
                if (!string.IsNullOrEmpty(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                Reporter.WriteVerbose(Resources.WritingFile(_output.Value()));
                File.WriteAllText(output, sql, Encoding.UTF8);
            }

            return(base.Execute(args));
        }