<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/0b630904c4589caaca33fa5e4405a9ea860eae22">https://github.com/macports/macports-base/commit/0b630904c4589caaca33fa5e4405a9ea860eae22</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 0b630904c4589caaca33fa5e4405a9ea860eae22
</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 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
<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 4808163..295065c 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;'>@@ -643,6 +643,61 @@ 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.204") < 0) {
</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_204_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.204' 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_204_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;'>@@ -652,7 +707,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.203") > 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (sql_version(NULL, -1, version, -1, "1.204") > 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>