示例#1
0
        public async Task SchemaUpdateAddsIndexesThatWerentPresentYetAsync()
        {
            Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();

            cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", GetType().Assembly);
            var su = new SchemaUpdate(cfg);
            var sb = new StringBuilder(500);

            await(su.ExecuteAsync(x => sb.AppendLine(x), false));
            Assert.That(sb.ToString(), Does.Contain("create index test_index_name on TestIndex (Name)"));
        }
        public async Task SchemaExport_Update_CreatesUpdateScriptAsync()
        {
            Configuration configuration = GetConfiguration();
            SchemaUpdate  update        = new SchemaUpdate(configuration);
            TextWriter    tw            = new StringWriter();

            await(update.ExecuteAsync(tw.WriteLine, false));

            string s = tw.ToString();

            Assert.IsTrue(s.Contains("create table Home_Update"));
            Assert.IsTrue(s.Contains("create table Home_All"));
        }
示例#3
0
        public async Task SchemaExport_Update_CreatesUpdateScriptAsync()
        {
            Configuration configuration = GetConfiguration();
            SchemaUpdate  update        = new SchemaUpdate(configuration);
            TextWriter    tw            = new StringWriter();

            await(update.ExecuteAsync(tw.WriteLine, false));

            string s = tw.ToString();

            Assert.That(s, Does.Match("create ((column|row) )?table Home_Update"));
            Assert.That(s, Does.Match("create ((column|row) )?table Home_All"));
        }
示例#4
0
        public async Task MigrateSchemaAsync()
        {
            //Lock the Migration processing
            await _semaphoreSlim.WaitAsync();

            try {
                this.Logger.LogInformation("Starting to migrate the schema of database...");
                var startTime = _clock.UtcNow;
                var update    = new SchemaUpdate(_cfg);
                await update.ExecuteAsync(false, true);

                var elapsedTime = _clock.UtcNow - startTime;
                this.Logger.LogInformation("The schema of Database has been migrated successfully. Elapsed time: {0}", elapsedTime.ToString());
            }
            finally {
                _semaphoreSlim.Release();
            }
        }