<pre style='margin:0'>
Umesh Singla (umeshksingla) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/db970cbc9fdc32b153f80317453e5b5af07427bf">https://github.com/macports/macports-base/commit/db970cbc9fdc32b153f80317453e5b5af07427bf</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/gsoc17-migrate by this push:
<span style='display:block; white-space:pre;color:#404040;'> new db970cb Add snapshot tables to update_db function
</span>db970cb is described below
<span style='display:block; white-space:pre;color:#808000;'>commit db970cbc9fdc32b153f80317453e5b5af07427bf
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Sun Jun 18 20:31:09 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> Add snapshot tables to update_db function
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> so that older installations get them too. Also, update the registry
</span><span style='display:block; white-space:pre;color:#404040;'> database version to 1.203
</span>---
src/cregistry/sql.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 58 insertions(+), 2 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/sql.c b/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 1df6538..944faab 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -134,7 +134,7 @@ int create_tables(sqlite3* db, reg_error* errPtr) {
</span>
/* metadata table */
"CREATE TABLE registry.metadata (key UNIQUE, value)",
<span style='display:block; white-space:pre;background:#ffe0e0;'>- "INSERT INTO registry.metadata (key, value) VALUES ('version', '1.202')",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "INSERT INTO registry.metadata (key, value) VALUES ('version', '1.203')",
</span> "INSERT INTO registry.metadata (key, value) VALUES ('created', strftime('%s', 'now'))",
/* ports table */
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -614,6 +614,62 @@ int update_db(sqlite3* db, reg_error* errPtr) {
</span> continue;
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (sql_version(NULL, -1, version, -1, "1.203") < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SQLite doesn't support ALTER TABLE DROP CONSTRAINT or ALTER
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * TABLE DROP COLUMN, so we're doing the manual way to remove
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * UNIQUE(url, epoch, version, revision, variants) and the url
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * column.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static char* version_1_203_queries[] = {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* snapshots table */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE TABLE registry.snapshots ("
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "id INTEGER PRIMARY KEY"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", created_at DATETIME"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", note TEXT"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ")",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE INDEX registry.snapshot ON snapshots(id)",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* snapshot ports table */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE TABLE registry.snapshot_ports ("
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "id INTEGER"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", port_name TEXT COLLATE NOCASE"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", requested INTEGER"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", FOREIGN KEY(id) REFERENCES snapshots(id))",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE INDEX registry.snapshot_ports ON snapshot_ports"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "(id, port_name)",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* snapshot port variants table */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE TABLE registry.snapshot_port_variants ("
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "id INTEGER"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", variant_name TEXT COLLATE NOCASE"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", variant_sign TEXT"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ", FOREIGN KEY(id) REFERENCES snapshot_ports(id))",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CREATE INDEX registry.snapshot_port_variants ON snapshot_port_variants(id)",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Update version and commit */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "UPDATE registry.metadata SET value = '1.203' WHERE key = 'version'",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "COMMIT",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ NULL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sqlite3_finalize(stmt);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ stmt = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!do_queries(db, version_1_203_queries, errPtr)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rollback_db(db);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ did_update = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /* add new versions here, but remember to:
* - finalize the version query statement and set stmt to NULL
* - do _not_ use "BEGIN" in your query list, since a transaction has
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -623,7 +679,7 @@ int update_db(sqlite3* db, reg_error* errPtr) {
</span> * - update the current version number below
*/
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if (sql_version(NULL, -1, version, -1, "1.202") > 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (sql_version(NULL, -1, version, -1, "1.203") > 0) {
</span> /* the registry was already upgraded to a newer version and cannot be used anymore */
reg_throw(errPtr, REG_INVALID, "Version number in metadata table is newer than expected.");
sqlite3_finalize(stmt);
</pre><pre style='margin:0'>
</pre>