DBSchema.h (1660B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef dom_indexeddb_dbschema_h__ 8 #define dom_indexeddb_dbschema_h__ 9 10 #include <cstdint> 11 12 #include "ErrorList.h" 13 14 class mozIStorageConnection; 15 16 namespace mozilla::dom::indexedDB { 17 18 // Major schema version. Bump for almost everything. 19 const uint32_t kMajorSchemaVersion = 26; 20 21 // Minor schema version. Should almost always be 0 (maybe bump on release 22 // branches if we have to). 23 const uint32_t kMinorSchemaVersion = 0; 24 25 // The schema version we store in the SQLite database is a (signed) 32-bit 26 // integer. The major version is left-shifted 4 bits so the max value is 27 // 0xFFFFFFF. The minor version occupies the lower 4 bits and its max is 0xF. 28 static_assert(kMajorSchemaVersion <= 0xFFFFFFF, 29 "Major version needs to fit in 28 bits."); 30 static_assert(kMinorSchemaVersion <= 0xF, 31 "Minor version needs to fit in 4 bits."); 32 33 constexpr int32_t MakeSchemaVersion(uint32_t aMajorSchemaVersion, 34 uint32_t aMinorSchemaVersion) { 35 return int32_t((aMajorSchemaVersion << 4) + aMinorSchemaVersion); 36 } 37 38 constexpr int32_t kSQLiteSchemaVersion = 39 MakeSchemaVersion(kMajorSchemaVersion, kMinorSchemaVersion); 40 41 nsresult CreateFileTables(mozIStorageConnection& aConnection); 42 nsresult CreateTables(mozIStorageConnection& aConnection); 43 44 } // namespace mozilla::dom::indexedDB 45 46 #endif