Beispiel #1
0
        private void UpdateSelf()
        {
            var migrator = new SchemaMigrationExecutor(_runner, GetMigratorTasks(), SchemaName);

            using (var t = _db.BeginTransaction())
            {
                if (!_db.DatabaseTools().TableExists(TableName))
                {
                    migrator.InstallSchema();
                    AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                }
                else
                {
                    var latest = GetInstalledVersion(SchemaName);
                    if (latest.IsNullOrEmpty())
                    {
                        migrator.InstallSchema();
                        AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                    }
                    else
                    {
                        if (latest != migrator.LatestVersionAvailable)
                        {
                            migrator.MigrateToLatestFrom(latest);
                            AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                        }
                    }
                }

                t.Commit();
            }
        }
Beispiel #2
0
        private void UpdateSelf()
        {
            var migrator = new SchemaMigrationExecutor(_runner, GetMigratorTasks(), SchemaName);

            using (var t = _db.BeginTransaction())
            {
                if (!_db.DatabaseTools().TableExists(TableName))
                {
                    migrator.InstallSchema();
                    AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                }
                else
                {
                    var latest = GetInstalledVersion(SchemaName);
                    if (latest.IsNullOrEmpty())
                    {
                        migrator.InstallSchema();
                        AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                    }
                    else
                    {
                        if (latest != migrator.LatestVersionAvailable)
                        {
                            migrator.MigrateToLatestFrom(latest);
                            AppendVersion(SchemaName, migrator.LatestVersionAvailable);
                        }
                    }
                }

                t.Commit();
            }
        }
Beispiel #3
0
        public void two_versions_of_setup_Db_throws()
        {
            _tasks.Add(new InstallerTask());
            var s = new SchemaMigrationExecutor(new FakeRunner(), _tasks, "TestSchema");

            Assert.Throws <InvalidOperationException>(() => s.InstallSchema());
        }
Beispiel #4
0
 public void setup_latest_version()
 {
     _schema.InstallSchema();
     Assert.Equal("1.0.2", _sb.ToString());
 }