public IProcessor Create(ProcessorOptions options, ILogger logger)
        {
            var generatorOptions = new GeneratorOptions();
            var quoter           = new SqlServer2005Quoter();
            var generator        = new SqlServer2005Generator(quoter, generatorOptions);

            return(new SqlServer2005Processor(logger, generator, options));
        }
예제 #2
0
 /// <inheritdoc />
 public SqlServer2005Processor(ILogger logger,
                               SqlServer2005Generator generator,
                               ProcessorOptions options)
     : base(new[] {
     "SqlServer2005",
     "SqlServer"
 }, generator, logger, options)
 {
 }
 public SqlServer2005Processor(
     [NotNull] ILogger <SqlServer2005Processor> logger,
     [NotNull] SqlServer2005Quoter quoter,
     [NotNull] SqlServer2005Generator generator,
     [NotNull] IOptionsSnapshot <ProcessorOptions> options,
     [NotNull] IConnectionStringAccessor connectionStringAccessor,
     [NotNull] IServiceProvider serviceProvider)
     : base(new[] { "SqlServer2005", "SqlServer" }, generator, quoter, logger, options, connectionStringAccessor, serviceProvider)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlServer2005Processor"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="quoter">The quoter.</param>
 /// <param name="generator">The migration generator.</param>
 /// <param name="options">The processor options.</param>
 /// <param name="connectionStringAccessor">The connection string accessor.</param>
 /// <param name="batchParserFactory"></param>
 public SqlServer2005Processor(
     [NotNull] ILogger <SqlServer2005Processor> logger,
     [NotNull] SqlServer2005Quoter quoter,
     [NotNull] SqlServer2005Generator generator,
     [NotNull] IOptionsSnapshot <ProcessorOptions> options,
     [NotNull] IConnectionStringAccessor connectionStringAccessor,
     [NotNull] SqlServerBatchParserFactory batchParserFactory)
     : base(new[] { "SqlServer2005", "SqlServer" }, SqlClientFactory.Instance, generator, quoter, logger, options, connectionStringAccessor, batchParserFactory)
 {
 }
        public IMigrationProcessor CreateMigrationProcessor(RunnerContext context, IDbConnection connection)
        {
            var isClose = connection.State != ConnectionState.Open;

            try
            {
                if (isClose)
                {
                    connection.Open();
                }

                IMigrationGenerator migrationGenerator;
                using (var command = new SqlCommand("SELECT CAST(LEFT(CAST(SERVERPROPERTY('productversion') AS varchar(50)),CHARINDEX('.',CAST(SERVERPROPERTY('productversion') AS varchar(50)))-1)AS int)", connection as SqlConnection))
                {
                    var version = (int)command.ExecuteScalar();
                    switch (version)
                    {
                    case 9:
                        migrationGenerator = new SqlServer2005Generator();
                        break;

                    case 10:
                        migrationGenerator = new SqlServer2008Generator();
                        break;

                    default:
                        migrationGenerator = new SqlServer2012Generator();
                        //                            throw new Exception(string.Format("无法识别的数据库版本:{0}。", version));
                        break;
                    }
                }

                return(new SqlServerProcessor(
                           connection
                           , migrationGenerator
                           , context.Announcer,
                           new ProcessorOptions
                {
                    PreviewOnly = context.PreviewOnly,
                    ProviderSwitches = context.ProviderSwitches,
                    Timeout = context.Timeout
                }
                           , new SqlServerDbFactory()));
            }
            finally
            {
                if (!isClose)
                {
                    connection.Close();
                }
            }
        }
예제 #6
0
        MigrationRunner getRunner()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["dahliaSQL"].ConnectionString;
            var connection       = new SqlConnection(connectionString);
            var assembly         = typeof(SqlMigrationService).Assembly;
            var ns        = typeof(SqlMigrationService).Namespace;
            var generator = new SqlServer2005Generator();
            var processor = new SqlServerProcessor(connection, generator, new NullAnnouncer(), new ProcessorOptions());

            return(new MigrationRunner(assembly, new RunnerContext(new NullAnnouncer())
            {
                Namespace = ns
            },
                                       processor));
        }
예제 #7
0
        protected static void ExecuteWithSqlServer2005(Action <IMigrationProcessor> test, bool tryRollback)
        {
            var serverOptions = IntegrationTestOptions.SqlServer2005;

            if (!serverOptions.IsEnabled)
            {
                return;
            }

            var announcer = new TextWriterAnnouncer(System.Console.Out);

            announcer.Heading("Testing Migration against MS SQL Server 2005");
            var generator = new SqlServer2005Generator();

            ExecuteWithSqlServer(serverOptions, announcer, generator, test, tryRollback);
        }
예제 #8
0
        private static void ExecuteWithSqlServer(IntegrationTestOptions.DatabaseServerOptions serverOptions, TextWriterAnnouncer announcer, SqlServer2005Generator generator, Action <IMigrationProcessor> test, bool tryRollback)
        {
            using (var connection = new SqlConnection(serverOptions.ConnectionString))
            {
                var processor = new SqlServerProcessor(connection, generator, announcer, new ProcessorOptions(), new SqlServerDbFactory());
                test(processor);

                if (tryRollback && !processor.WasCommitted)
                {
                    processor.RollbackTransaction();
                }
            }
        }
 public void Setup()
 {
     Generator = new SqlServer2005Generator();
 }
 public void Setup()
 {
     generator = new SqlServer2005Generator();
 }