Beispiel #1
0
        public IEnumerable <ISchemaChange> GetAllChanges()
        {
            var previousVersion = new DatabaseVersion(1, 0, 0, 0);

            return((from majorVersionFolder in Directory.GetDirectories(_pathToSchemaScripts).Where(d => IsVersionFolder(d))
                    let majorVersion = GetMajorVersion(majorVersionFolder)
                                       from schemaChangeFolder in Directory.GetDirectories(majorVersionFolder).Where(d => IsSchemaChangeFolder(d))
                                       let minorVersion = GetMinorVersion(schemaChangeFolder)
                                                          let currentVersion = DatabaseVersion.FromString(majorVersion + "." + minorVersion)
                                                                               select new SchemaChange(Path.GetFullPath(schemaChangeFolder), currentVersion, previousVersion, _options))
                   .Do(s => previousVersion = s.Version)
                   .OrderBy(s => s.Version)
                   .Cast <ISchemaChange>());
        }
        private DatabaseVersion LoadRevision()
        {
            using (var command = _context.CreateCommand())
            {
                command.CommandText = "SELECT COUNT(*) FROM sys.extended_properties WHERE name = 'DatabaseVersion'";
                var count = (int)command.ExecuteScalar();

                if (count == 0)
                {
                    command.CommandText = "exec sp_addextendedproperty @name='DatabaseVersion', @value='1.0.0.0'";
                    command.ExecuteNonQuery();
                }

                command.CommandText = "SELECT value FROM sys.extended_properties WHERE name = 'DatabaseVersion'";
                var value = (string)command.ExecuteScalar();

                return(DatabaseVersion.FromString(value));
            }
        }
            public void then_it_sets_the_version_correctly_in_the_database()
            {
                var version = Context.ExecuteScalar <string>("select value from sys.extended_properties WHERE name = 'DatabaseVersion'");

                DatabaseVersion.FromString(version).ShouldLookLike(new DatabaseVersion(2, 3, 4, 5));
            }
 protected override void When()
 {
     _result = DatabaseVersion.FromString("1.2.6.13");
 }
 protected override void When()
 {
     _result = Assert.Throws <ArgumentException>(() => DatabaseVersion.FromString("1"));
 }