Revision 77c71baf src/onedb/database_schema.rb

View differences:

src/onedb/database_schema.rb
14 14
# limitations under the License.                                             #
15 15
#--------------------------------------------------------------------------- #
16 16

  
17
require "rubygems"
18

  
17 19
class OneDBBacKEnd
18 20
    SCHEMA = {
19 21
        cluster_pool: "oid INTEGER PRIMARY KEY, name VARCHAR(128), " <<
......
64 66
                       "body MEDIUMTEXT, uid INTEGER, gid INTEGER, " <<
65 67
                       "owner_u INTEGER, group_u INTEGER, other_u INTEGER, " <<
66 68
                       "UNIQUE(name)"
67
        }
69
        },
70
        "5.4.0" => {}
68 71
    }
69 72

  
70
    LATEST_DB_VERSION = "5.3.80"
73
    LATEST_DB_VERSION = "5.4.0"
71 74

  
72 75
    def get_schema(type, version = nil)
73 76
        if !version
......
78 81
            end
79 82
        end
80 83

  
81
        version_schema = VERSION_SCHEMA[version] || {}
82
        schema = SCHEMA.merge(version_schema)[type]
84
        gver = Gem::Version.new(version)
85

  
86
        # Discard versions greater than the one we are searching for
87
        versions = VERSION_SCHEMA.keys.reject do |v|
88
            Gem::Version.new(v) > gver
89
        end
90

  
91
        # Order versions in decreasing order
92
        versions.sort! do |a, b|
93
            Gem::Version.new(b) <=> Gem::Version.new(a)
94
        end
95

  
96
        schema = nil
97

  
98
        # Find latest type definition
99
        versions.each do |v|
100
            schema = VERSION_SCHEMA[v][type]
101
            next if schema
102
        end
103

  
104
        schema = SCHEMA[type] if !schema
83 105

  
84 106
        if !schema
85 107
            STDERR.puts "Schema not found (#{type}) for version #{version}"

Also available in: Unified diff