OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | |
6 #define SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "sync/syncable/entry_kernel.h" | |
10 #include "sync/syncable/syncable_changes_version.h" | |
11 | |
12 namespace syncer { | |
13 namespace syncable { | |
14 | |
15 struct ColumnSpec { | |
16 const char* name; | |
17 const char* spec; | |
18 }; | |
19 | |
20 // Must be in exact same order as fields in entry_kernel.h. | |
21 static const ColumnSpec g_metas_columns[] = { | |
22 ////////////////////////////////////// | |
23 // int64s | |
24 {"metahandle", "bigint primary key ON CONFLICT FAIL"}, | |
25 {"base_version", "bigint default " CHANGES_VERSION_STRING}, | |
26 {"server_version", "bigint default 0"}, | |
27 // This is the item ID that we store for the embedding application. | |
28 {"local_external_id", "bigint default 0"}, | |
29 {"transaction_version", "bigint default 0"}, | |
30 // These timestamps are kept in the same format as that of the | |
31 // protocol (ms since Unix epoch). | |
32 {"mtime", "bigint default 0"}, | |
33 {"server_mtime", "bigint default 0"}, | |
34 {"ctime", "bigint default 0"}, | |
35 {"server_ctime", "bigint default 0"}, | |
36 ////////////////////////////////////// | |
37 // Ids | |
38 {"id", "varchar(255) default \"r\""}, | |
39 {"parent_id", "varchar(255) default \"r\""}, | |
40 {"server_parent_id", "varchar(255) default \"r\""}, | |
41 ////////////////////////////////////// | |
42 // bits | |
43 {"is_unsynced", "bit default 0"}, | |
44 {"is_unapplied_update", "bit default 0"}, | |
45 {"is_del", "bit default 0"}, | |
46 {"is_dir", "bit default 0"}, | |
47 {"server_is_dir", "bit default 0"}, | |
48 {"server_is_del", "bit default 0"}, | |
49 ////////////////////////////////////// | |
50 // Strings | |
51 {"non_unique_name", "varchar"}, | |
52 {"server_non_unique_name", "varchar(255)"}, | |
53 {"unique_server_tag", "varchar"}, | |
54 {"unique_client_tag", "varchar"}, | |
55 {"unique_bookmark_tag", "varchar"}, | |
56 ////////////////////////////////////// | |
57 // Blobs (serialized protos). | |
58 {"specifics", "blob"}, | |
59 {"server_specifics", "blob"}, | |
60 {"base_server_specifics", "blob"}, | |
61 ////////////////////////////////////// | |
62 // Blobs (positions). | |
63 {"server_unique_position", "blob"}, | |
64 {"unique_position", "blob"}, | |
65 ////////////////////////////////////// | |
66 // AttachmentMetadata is a proto that contains all the metadata associated | |
67 // with an entry's attachments. Each entry has only one AttachmentMetadata | |
68 // proto. We store a single proto per entry (as opposed to one for each | |
69 // attachment) because it simplifies the database schema and implementation of | |
70 // DirectoryBackingStore. | |
71 {"attachment_metadata", "blob"}, | |
72 {"server_attachment_metadata", "blob"} | |
73 }; | |
74 | |
75 // At least enforce that there are equal number of column names and fields. | |
76 static_assert(arraysize(g_metas_columns) >= FIELD_COUNT, "missing column name"); | |
77 static_assert(arraysize(g_metas_columns) <= FIELD_COUNT, "extra column names"); | |
78 | |
79 static inline const char* ColumnName(int field) { | |
80 DCHECK(field < BEGIN_TEMPS); | |
81 return g_metas_columns[field].name; | |
82 } | |
83 | |
84 } // namespace syncable | |
85 } // namespace syncer | |
86 | |
87 #endif // SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | |
OLD | NEW |