Ejemplo n.º 1
0
        private void ApplyCustomBootstrapping(Versioning versioning, ComposablePartCatalog catalog)
        {
            var timestampProviders = InitializeTimestampProviders(catalog, _options.ModuleSelector);

            using (IDbConnection connection = _dbConnectionFactory.OpenConnection(_connectionInfo))
            {
                using (IDbTransaction transaction = _connectionInfo.SupportsTransactions ? connection.BeginTransaction() : null)
                {
                    _customBootstrapper.BeginBootstrapping(connection, transaction);

                    // bootstrapping is a "global" operation; therefore we need to call IsContained on *all* migrations
                    var allMigrations = ImportAllMigrations(catalog, timestampProviders)
                                        .Select(m => m.Metadata);
                    var migrationsContainedAtBootstrapping = from m in allMigrations
                                                             where _customBootstrapper.IsContained(m)
                                                             select m;
                    versioning.UpdateToInclude(migrationsContainedAtBootstrapping, connection, transaction);
                    _customBootstrapper.EndBootstrapping(connection, transaction);
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ApplyCustomBootstrapping(Versioning versioning, ContainerConfiguration containerConfiguration)
        {
            var timestampProviders = InitializeTimestampProviders(containerConfiguration);

            using (IDbConnection connection = Configuration.OpenConnection())
            {
                using (IDbTransaction transaction = Configuration.ConnectionInfo.SupportsTransactions ? connection.BeginTransaction() : null)
                {
                    _customBootstrapper.BeginBootstrapping(connection, transaction);

                    // bootstrapping is a "global" operation; therefore we need to call IsContained on *all* migrations
                    var importer      = new MigrationImporter(containerConfiguration, timestampProviders);
                    var allMigrations = importer.ImportMigrations()
                                        .Select(m => m.Metadata);
                    var migrationsContainedAtBootstrapping = allMigrations.Where(m => _customBootstrapper.IsContained(m));
                    versioning.UpdateToInclude(migrationsContainedAtBootstrapping, connection, transaction);
                    _customBootstrapper.EndBootstrapping(connection, transaction);
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }