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