Skip to content

Instantly share code, notes, and snippets.

@billymeltdown
Last active August 29, 2015 14:14
Show Gist options
  • Save billymeltdown/485b73bf81ca4ea7cfe6 to your computer and use it in GitHub Desktop.
Save billymeltdown/485b73bf81ca4ea7cfe6 to your computer and use it in GitHub Desktop.
A snippet of ditto
static void ditto_createFunc(sqlite3_context *context, int argc, sqlite3_value **argv) {
sqlite3 *db = sqlite3_context_db_handle(context);
if(ditto_exec(db,
"CREATE TABLE ditto_log ("
" rep_id TEXT NOT NULL,"
" csn INTEGER NOT NULL,"
" timestamp DATETIME NOT NULL,"
" type TEXT NOT NULL,"
" object_name TEXT NOT NULL,"
" object_guid TEXT NOT NULL,"
" operation TEXT NOT NULL,"
" diff TEXT"
");",
-1) != SQLITE_OK) {
sqlite3_result_error(context, "ditto create error creating ditto_log table ", -1);
}
if(ditto_exec(db,
"CREATE TABLE ditto_reps ("
" rep_id TEXT PRIMARY KEY,"
" is_local INTEGER NOT NULL,"
" csn INTEGER NOT NULL"
");",
-1) != SQLITE_OK) {
sqlite3_result_error(context, "ditto create error creating ditto_reps table ", -1);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment