[−][src]Module logins::schema
Logins Schema v4
The schema we use is a evolution of the firefox-ios logins database format. There are three tables:
loginsL
: The local table.loginsM
: The mirror table.loginsSyncMeta
: The table used to to store various sync metadata.
loginsL
This stores local login information, also known as the "overlay".
loginsL
is essentially unchanged from firefox-ios, however note the
semantic change v4 makes to timestamp fields (which is explained in more
detail in the [COMMON_COLS] documentation).
It is important to note that loginsL
is not guaranteed to be present for
all records. Synced records may only exist in loginsM
(although this is
not guaranteed). In either case, queries should read from both loginsL
and
loginsM
.
loginsL
Columns
Contains all fields in [COMMON_COLS], as well as the following additional columns:
-
local_modified
: A millisecond local timestamp indicating when the record was changed locally, or NULL if the record has never been changed locally. -
is_deleted
: A boolean indicating whether or not this record is a tombstone. -
sync_status
: ASyncStatus
enum value, one of-
0
(SyncStatus::Synced
): Indicating that the record has been synced -
1
(SyncStatus::Changed
): Indicating that the record should be has changed locally and is known to exist on the server. -
2
(SyncStatus::New
): Indicating that the record has never been synced, or we have been reset since the last time it synced.
-
loginsM
This stores server-side login information, also known as the "mirror".
Like loginsL
, loginM
has not changed from firefox-ios, beyond the
change to store timestamps as milliseconds explained in [COMMON_COLS].
Also like loginsL
, loginsM
is not guaranteed to have rows for all
records. It should not have rows for records which were not synced!
It is important to note that loginsL
is not guaranteed to be present for
all records. Synced records may only exist in loginsM
! Queries should
test against both!
loginsM
Columns
Contains all fields in [COMMON_COLS], as well as the following additional columns:
-
server_modified
: the most recent server-modification timestamp ([sync15::ServerTimestamp]) we've seen for this record. Stored as a millisecond value. -
is_overridden
: A boolean indicating whether or not the mirror contents are invalid, and that we should defer to the data stored inloginsL
.
loginsSyncMeta
This is a simple key-value table based on the moz_meta
table in places.
This table was added (by this rust crate) in version 4, and so is not
present in firefox-ios.
Currently it is used to store two items:
-
The last sync timestamp is stored under [LAST_SYNC_META_KEY], a
sync15::ServerTimestamp
stored in integer milliseconds. -
The persisted sync state machine information is stored under [GLOBAL_STATE_META_KEY]. This is a
sync15::GlobalState
stored as JSON.
Structs
CREATE_LOCAL_TABLE_SQL | |
CREATE_MIRROR_TABLE_SQL | |
SET_VERSION_SQL |
Constants
COMMON_COLS | Every column shared by both tables except for |
COMMON_SQL | |
CREATE_DELETED_HOSTNAME_INDEX_SQL | |
CREATE_META_TABLE_SQL | |
CREATE_OVERRIDE_HOSTNAME_INDEX_SQL | |
UPDATE_LOCAL_TIMESTAMPS_TO_MILLIS_SQL | |
UPDATE_MIRROR_TIMESTAMPS_TO_MILLIS_SQL | |
VERSION | Note that firefox-ios is currently on version 3. Version 4 is this version, which adds a metadata table and changes timestamps to be in milliseconds |
Statics
COLLECTION_SYNCID_META_KEY | |
GLOBAL_STATE_META_KEY | |
GLOBAL_SYNCID_META_KEY | |
LAST_SYNC_META_KEY |
Functions
create | |
drop | |
init | |
upgrade |