jcs
/subtext
/amendments
/516
db: Remove a bunch of old migrations
jcs made amendment 516 over 2 years ago
--- db.c	Thu Jun 15 10:22:32 2023
+++ db.c	Thu Jun 15 14:12:40 2023
@@ -402,201 +402,20 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa
 		  (short)(ver + 1));
 		
 		switch (ver) {
-		case 1: {
-			/* 1->2, added user is_enabled field */
-			struct user user;
-			size_t nusers, n;
-			unsigned long *ids = NULL;
-			
-			nusers = bile_sorted_ids_by_type(tdb->bile, DB_USER_RTYPE,
-			  &ids);
-			for (n = 0; n < nusers; n++) {
-				memset(&user, 0, sizeof(user));
-				bile_read(tdb->bile, DB_USER_RTYPE, ids[n], (char *)&user,
-				  sizeof(user));
-				user.is_enabled = DB_TRUE;
-				bile_write(tdb->bile, DB_USER_RTYPE, ids[n], (char *)&user,
-				  sizeof(user));
-			}
-			if (ids)
-				xfree(&ids);
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+		case 5:
+		case 6:
+		case 7:
+		case 8:
+		case 9:
+		case 10:
+		case 11:
+			panic("This version of Subtext is too old to upgrade, please "
+			  "upgrade to a previous release first.");
 			break;
-		}
-		case 2: {
-			/* 2->3, added config open_signup field */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.open_signup = 0;
-			
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 3: {
-			/* 3->4, added max_login_seconds */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.max_login_seconds = 90;
-
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 4: {
-			/* 4->5, added blanker fields */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.blanker_idle_seconds = (60 * 60);
-			new_config.blanker_runtime_seconds = 30;
-			
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 5: {
-			/* 5->6, added trusted_proxy_ip */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.trusted_proxy_ip = 0;
-			
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 6: {
-			/* 6->7, added modem_speed */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.modem_speed = 19200;
-			
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 7: {
-			/* 7->8, added trusted_proxy_udp_port */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.trusted_proxy_udp_port = 0;
-			
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 8: {
-			/* 8->9, added user.last_motd_seen */
-			struct user user;
-			size_t nusers, n;
-			unsigned long *ids = NULL;
-			
-			nusers = bile_sorted_ids_by_type(tdb->bile, DB_USER_RTYPE,
-			  &ids);
-			for (n = 0; n < nusers; n++) {
-				memset(&user, 0, sizeof(user));
-				bile_read(tdb->bile, DB_USER_RTYPE, ids[n], (char *)&user,
-				  sizeof(user));
-				user.last_motd_seen = 0;
-				bile_write(tdb->bile, DB_USER_RTYPE, ids[n], (char *)&user,
-				  sizeof(user));
-			}
-			if (ids)
-				xfree(&ids);
-			break;
-		}
-		case 9: {
-			/* 9->10, added board post via */
-			size_t nposts, n, j, size;
-			unsigned long *ids = NULL;
-			struct board *board;
-			char *data;
-			struct board_post post;
-			short ret;
-			
-			db_cache_boards(tdb);
-			
-			for (n = 0; n < tdb->nboards; n++) {
-				board = &tdb->boards[n];
-				nposts = bile_sorted_ids_by_type(board->bile,
-				  BOARD_POST_RTYPE, &ids);
-				for (j = 0; j < nposts; j++) {
-					size = bile_read_alloc(board->bile, BOARD_POST_RTYPE,
-					  ids[j], &data);
-					if (size == 0)
-						panic("failed fetching message %ld: %d", ids[j],
-						  bile_error(board->bile));
-					
-					/* pretend we read this much, just fill via with junk */
-					size += member_size(struct board_post, via);
-					
-					bile_unmarshall_object(board->bile,
-					  board_post_object_fields, nboard_post_object_fields,
-					  data, size, &post, sizeof(post), true);
-					xfree(&data);
-					
-					/* zero out junk */
-					memset(&post.via, 0, sizeof(post.via));
-					
-					ret = bile_marshall_object(board->bile,
-					  board_post_object_fields, nboard_post_object_fields,
-					  &post, &data, &size);
-					if (ret != 0 || size == 0)
-						panic("failed to marshall new post object");
-					if (bile_write(board->bile, BOARD_POST_RTYPE,
-					  post.id, data, size) != size)
-						panic("bile_write of post failed! %d",
-						  bile_error(board->bile));
-					
-					xfree(&data);
-				}
-				if (ids != NULL)
-					xfree(&ids);
-			}
-			break;
-		}
-		case 10: {
-			/* 10->11, added session_log_prune_days */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			new_config.session_log_prune_days = 21;
-
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
-		case 11: {
-			/* 11->12, added modem_parity */
-			struct config new_config = { 0 };
-			
-			bile_read(tdb->bile, DB_CONFIG_RTYPE, 1, (char *)&new_config,
-			  sizeof(new_config));
-			  
-			sprintf(new_config.modem_parity, "8N1");
-
-			bile_write(tdb->bile, DB_CONFIG_RTYPE, 1, &new_config,
-			  sizeof(new_config));
-			break;
-		}
 		case 12: {
 			/* 12->13, added ftn/binkp fields */
 			struct config new_config = { 0 };