Fossil SCM

Change the schema for the synclog table so that there are separate rows for transfers in each direction.

drh 2021-12-19 19:59 synclog
Commit 1ec46849ff5e065f9edc1469c09ee95ad4e5b58c8353e5055c3c4e83d9008f1c
2 files changed +2 -4 +14 -19
+2 -4
--- src/schema.c
+++ src/schema.c
@@ -628,14 +628,12 @@
628628
*/
629629
static const char zSynclogSchema[] =
630630
@ CREATE TABLE repository.synclog(
631631
@ sfrom TEXT, -- Sync client. "self" means this repo
632632
@ sto TEXT, -- Sync server
633
-@ spush DATETIME, -- Time of last push (julian day)
634
-@ spull DATETIME, -- Time of last pull (julian day)
635
-@ sdist INT, -- Distance from this repo. 0 means self
636
-@ stype TEXT, -- Type of "sto". ex: "git","backup". NULL means fossil
633
+@ stime DATETIME, -- Time of transfer (julian day)
634
+@ stype TEXT, -- "push", "pull", "git", "backup", "import", etc...
637635
@ PRIMARY KEY(sfrom,sto)
638636
@ ) WITHOUT ROWID;
639637
;
640638
641639
/* Create the forum-post schema if it does not already exist */
642640
--- src/schema.c
+++ src/schema.c
@@ -628,14 +628,12 @@
628 */
629 static const char zSynclogSchema[] =
630 @ CREATE TABLE repository.synclog(
631 @ sfrom TEXT, -- Sync client. "self" means this repo
632 @ sto TEXT, -- Sync server
633 @ spush DATETIME, -- Time of last push (julian day)
634 @ spull DATETIME, -- Time of last pull (julian day)
635 @ sdist INT, -- Distance from this repo. 0 means self
636 @ stype TEXT, -- Type of "sto". ex: "git","backup". NULL means fossil
637 @ PRIMARY KEY(sfrom,sto)
638 @ ) WITHOUT ROWID;
639 ;
640
641 /* Create the forum-post schema if it does not already exist */
642
--- src/schema.c
+++ src/schema.c
@@ -628,14 +628,12 @@
628 */
629 static const char zSynclogSchema[] =
630 @ CREATE TABLE repository.synclog(
631 @ sfrom TEXT, -- Sync client. "self" means this repo
632 @ sto TEXT, -- Sync server
633 @ stime DATETIME, -- Time of transfer (julian day)
634 @ stype TEXT, -- "push", "pull", "git", "backup", "import", etc...
 
 
635 @ PRIMARY KEY(sfrom,sto)
636 @ ) WITHOUT ROWID;
637 ;
638
639 /* Create the forum-post schema if it does not already exist */
640
+14 -19
--- src/sync.c
+++ src/sync.c
@@ -111,32 +111,27 @@
111111
void sync_log_entry(
112112
int syncFlags, /* Indicates whether a PUSH or PULL or both */
113113
const char *zRemote, /* Server with which we push or pull */
114114
const char *zType /* Type of sync. NULL for normal */
115115
){
116
- const char *zPush;
117
- const char *zPull;
116
+ schema_synclog();
118117
if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
119
- zPull = "julianday()";
120
- }else{
121
- zPull = "NULL";
118
+ db_multi_exec(
119
+ "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
120
+ " VALUES(%Q,'this',julianday(),%Q)"
121
+ " ON CONFLICT DO UPDATE SET stime=julianday()",
122
+ zRemote, zType
123
+ );
122124
}
123125
if( syncFlags & (SYNC_PUSH) ){
124
- zPush = "julianday()";
125
- }else{
126
- zPush = "NULL";
127
- }
128
- schema_synclog();
129
- db_multi_exec(
130
- "INSERT INTO repository.synclog(sfrom,sto,spush,spull,sdist,stype)"
131
- " VALUES('self',%Q,%s,%s,0,%Q)"
132
- " ON CONFLICT DO UPDATE"
133
- " SET spush=coalesce(%s,spush),"
134
- " spull=coalesce(%s,spull);",
135
- zRemote, zPush/*safe-for-%s*/, zPull/*safe-for-%s*/, zType,
136
- zPush/*safe-for-%s*/, zPull/*safe-for-%s*/
137
- );
126
+ db_multi_exec(
127
+ "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
128
+ " VALUES('this',%Q,julianday(),%Q)"
129
+ " ON CONFLICT DO UPDATE SET stime=julianday()",
130
+ zRemote, zType
131
+ );
132
+ }
138133
}
139134
140135
141136
/*
142137
** If the repository is configured for autosyncing, then do an
143138
--- src/sync.c
+++ src/sync.c
@@ -111,32 +111,27 @@
111 void sync_log_entry(
112 int syncFlags, /* Indicates whether a PUSH or PULL or both */
113 const char *zRemote, /* Server with which we push or pull */
114 const char *zType /* Type of sync. NULL for normal */
115 ){
116 const char *zPush;
117 const char *zPull;
118 if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
119 zPull = "julianday()";
120 }else{
121 zPull = "NULL";
 
 
 
122 }
123 if( syncFlags & (SYNC_PUSH) ){
124 zPush = "julianday()";
125 }else{
126 zPush = "NULL";
127 }
128 schema_synclog();
129 db_multi_exec(
130 "INSERT INTO repository.synclog(sfrom,sto,spush,spull,sdist,stype)"
131 " VALUES('self',%Q,%s,%s,0,%Q)"
132 " ON CONFLICT DO UPDATE"
133 " SET spush=coalesce(%s,spush),"
134 " spull=coalesce(%s,spull);",
135 zRemote, zPush/*safe-for-%s*/, zPull/*safe-for-%s*/, zType,
136 zPush/*safe-for-%s*/, zPull/*safe-for-%s*/
137 );
138 }
139
140
141 /*
142 ** If the repository is configured for autosyncing, then do an
143
--- src/sync.c
+++ src/sync.c
@@ -111,32 +111,27 @@
111 void sync_log_entry(
112 int syncFlags, /* Indicates whether a PUSH or PULL or both */
113 const char *zRemote, /* Server with which we push or pull */
114 const char *zType /* Type of sync. NULL for normal */
115 ){
116 schema_synclog();
 
117 if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
118 db_multi_exec(
119 "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
120 " VALUES(%Q,'this',julianday(),%Q)"
121 " ON CONFLICT DO UPDATE SET stime=julianday()",
122 zRemote, zType
123 );
124 }
125 if( syncFlags & (SYNC_PUSH) ){
126 db_multi_exec(
127 "INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
128 " VALUES('this',%Q,julianday(),%Q)"
129 " ON CONFLICT DO UPDATE SET stime=julianday()",
130 zRemote, zType
131 );
132 }
 
 
 
 
 
 
 
133 }
134
135
136 /*
137 ** If the repository is configured for autosyncing, then do an
138

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button