Browse code

kamdbctl: remove not working db migrate command

- remove db migrate implementation in kamdbctl, .base, .mysql and .db_berkley files
- it was not working for mysql anyway, and not implemented for berkleydb
- this state was already documtend some weeks ago in commit 52a8def8d2a3e831

Henning Westerholt authored on 03/03/2018 18:08:30
Showing 4 changed files
... ...
@@ -288,29 +288,6 @@ kamailio_pframework() #pars: <action>
288 288
 
289 289
 
290 290
 case $1 in
291
-	migrate)
292
-		if [ "$USED_DBENGINE" != "mysql" ] ; then
293
-			merr "$USED_DBENGINE don't support migrate operation"
294
-			exit 1
295
-		fi
296
-		if [ $# -ne 3 ] ; then
297
-			merr "migrate requires 2 parameters: old and new database"
298
-			exit 1
299
-		fi
300
-		# create new database
301
-		minfo "Creating new Database $3...."
302
-		NO_USER_INIT="yes"
303
-		kamailio_create $3
304
-		if [ "$?" -ne 0 ] ; then
305
-			echo "migrate: creating new database failed"
306
-			exit 1
307
-		fi
308
-		# migrate data
309
-		minfo "Migrating data from $2 to $3...."
310
-		migrate_db $2 $3
311
-		minfo "Migration successfully completed."
312
-		exit 0;
313
-		;;
314 291
 	copy)
315 292
 		# copy database to some other name
316 293
 		if [ "$USED_DBENGINE" == "berkeley" -o "$USED_DBENGINE" == "dbtext" ] ; then
... ...
@@ -97,7 +97,6 @@ usage: $COMMAND create <db name or db_path, optional> ...(creates a new database
97 97
        $COMMAND backup <file> ...........................(dumps current database to file)
98 98
        $COMMAND restore <file> ..........................(restores tables from a file)
99 99
        $COMMAND copy <new_db> ...........................(creates a new db from an existing one)
100
-       $COMMAND migrate <old_db> <new_db> ...............(migrates DB - no longer maintained!)
101 100
        $COMMAND presence ................................(adds the presence related tables)
102 101
        $COMMAND extra ...................................(adds the extra tables)
103 102
        $COMMAND dbuid ...................................(adds the uid tables)
... ...
@@ -176,12 +176,6 @@ kamailio_berkeley()  # parms: <op> <arg1> <arg2>
176 176
 			exit $?
177 177
 			;;
178 178
 
179
-		migrate)
180
-			shift
181
-			kamailio_migrate $1 $DB_PATH
182
-			exit $?
183
-			;;
184
-
185 179
 		import)
186 180
 			shift
187 181
 			kamailio_import  $1 $DB_PATH
... ...
@@ -308,21 +302,6 @@ kamailio_export()  # parms: <DUMP_DIR> [DB_PATH]
308 302
 }
309 303
 
310 304
 
311
-##
312
-# MIGRATE (schema)
313
-# Examine each plain-txt file in DUMP_DIR
314
-#  (Assumes that kamailio_export was already invoked)
315
-#
316
-# Migrate converts data from schema-old to schema-new in place.
317
-#
318
-# After this step is complete the IMPORT should be executed.
319
-kamailio_migrate()  # parms: <DUMP_DIR> [DB_PATH]
320
-{
321
-	merr "db_berkeley migrate not implemented"
322
-	exit 1
323
-}
324
-
325
-
326 305
 ##
327 306
 # IMPORT existing plain-txt files from DUMP_DIR to DB_PATH
328 307
 # eg.  DUMP_DIR/version.txt  --> DB_PATH/version
... ...
@@ -373,172 +373,6 @@ kamailio_add_tables () # params: <database name> <tables group name>
373 373
 	fi
374 374
 }  # end kamailio_add_tables
375 375
 
376
-migrate_table () # 4 paremeters (dst_table, dst_cols, src_table, src_cols)
377
-{
378
-	if [ $# -ne 4 ] ; then
379
-		merr "migrate_table function takes 4 params $@"
380
-		exit 1
381
-	fi
382
-
383
-	src_cols=`echo $4 | sed s/?/$3./g `
384
-
385
-	X=`sql_query "" "INSERT into $1 ($2) SELECT $src_cols from $3;" 2>&1`
386
-
387
-	if [ $? -ne 0 ] ; then
388
-		echo $X | $GREP "ERROR 1146" > /dev/null
389
-		if [ $? -eq 0 ] ; then
390
-			echo " -- Migrating $3 to $1.....SKIPPED (no source)"
391
-			return 0
392
-		fi
393
-		echo "ERROR: failed to migrate $3 to $1!!!"
394
-		echo -n "Skip it and continue (y/n)? "
395
-		read INPUT
396
-		if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
397
-		then
398
-			return 0
399
-		fi
400
-
401
-		exit 1;
402
-	fi
403
-
404
-	minfo " -- Migrating $3 to $1.....OK"
405
-
406
-}
407
-
408
-migrate_db () # 2 parameters (src_db, dst_db)
409
-{
410
-if [ $# -ne 2 ] ; then
411
-	merr "migrate_db function takes 2 params"
412
-	exit 1
413
-fi
414
-
415
-dst_db=$2
416
-src_db=$1
417
-
418
-migrate_table ${dst_db}.acc \
419
-	"id,method,from_tag,to_tag,callid,sip_code,sip_reason,time" \
420
-	${src_db}.acc \
421
-	"?id,?method,?from_tag,?to_tag,?callid,?sip_code,?sip_reason,?time"
422
-
423
-migrate_table ${dst_db}.missed_calls \
424
-	"id,method,from_tag,to_tag,callid,sip_code,sip_reason,time" \
425
-	${src_db}.missed_calls \
426
-	"?id,?method,?from_tag,?to_tag,?callid,?sip_code,?sip_reason,?time"
427
-
428
-migrate_table ${dst_db}.aliases \
429
-	"id,username,domain,contact,expires,q,callid,cseq,last_modified,\
430
-		flags,cflags,user_agent" \
431
-	${src_db}.aliases \
432
-	"?id,?username,?domain,?contact,?expires,?q,?callid,?cseq,?last_modified,\
433
-		?flags,?cflags,?user_agent"
434
-
435
-migrate_table ${dst_db}.dbaliases \
436
-	"id,alias_username,alias_domain,username,domain" \
437
-	${src_db}.dbaliases \
438
-	"?id,?alias_username,?alias_domain,?username,?domain"
439
-
440
-migrate_table ${dst_db}.grp \
441
-	"id,username,domain,grp,last_modified" \
442
-	${src_db}.grp \
443
-	"?id,?username,?domain,?grp,?last_modified"
444
-
445
-migrate_table ${dst_db}.re_grp \
446
-	"id,reg_exp,group_id" \
447
-	${src_db}.re_grp \
448
-	"?id,?reg_exp,?group_id"
449
-
450
-migrate_table ${dst_db}.silo \
451
-	"id,src_addr,dst_addr,username,domain,inc_time,exp_time,snd_time,\
452
-		ctype,body" \
453
-	${src_db}.silo \
454
-	"?id,?src_addr,?dst_addr,?username,?domain,?inc_time,?exp_time,?snd_time,\
455
-		?ctype,?body"
456
-
457
-migrate_table ${dst_db}.domain \
458
-	"id,domain,last_modified" \
459
-	${src_db}.domain \
460
-	"?id,?domain,?last_modified"
461
-
462
-migrate_table ${dst_db}.uri \
463
-	"id,username,domain,uri_user,last_modified" \
464
-	${src_db}.uri \
465
-	"?id,?username,?domain,?uri_user,?last_modified"
466
-
467
-migrate_table ${dst_db}.usr_preferences \
468
-	"id,uuid,username,domain,attribute,type,value,last_modified" \
469
-	${src_db}.usr_preferences \
470
-	"?id,?uuid,?username,?domain,?attribute,?type,?value,?last_modified"
471
-
472
-migrate_table ${dst_db}.trusted \
473
-	"id,src_ip,proto,from_pattern,tag" \
474
-	${src_db}.trusted \
475
-	"?id,?src_ip,?proto,?from_pattern,?tag"
476
-
477
-migrate_table ${dst_db}.address \
478
-	"id,grp,ip_addr,mask,port" \
479
-	${src_db}.address \
480
-	"?id,?grp,?ip_addr,?mask,?port"
481
-
482
-migrate_table ${dst_db}.speed_dial \
483
-	"id,username,domain,sd_username,sd_domain,new_uri,\
484
-		fname,lname,description" \
485
-	${src_db}.speed_dial \
486
-	"?id,?username,?domain,?sd_username,?sd_domain,?new_uri,\
487
-		?fname,?lname,?description"
488
-
489
-migrate_table ${dst_db}.gw \
490
-	"id,gw_name,grp_id,ip_addr,port,uri_scheme,transport,strip,prefix" \
491
-	${src_db}.gw \
492
-	"?id,?gw_name,?grp_id,?ip_addr,?port,?uri_scheme,?transport,?strip,?prefix"
493
-
494
-migrate_table ${dst_db}.gw_grp \
495
-	"grp_id,grp_name" \
496
-	${src_db}.gw_grp \
497
-	"?grp_id,?grp_name"
498
-
499
-migrate_table ${dst_db}.lcr \
500
-	"id,prefix,from_uri,grp_id,priority" \
501
-	${src_db}.lcr \
502
-	"?id,?prefix,?from_uri,?grp_id,?priority"
503
-
504
-migrate_table ${dst_db}.pdt \
505
-	"id,sdomain,prefix,domain" \
506
-	${src_db}.pdt \
507
-	"?id,?sdomain,?prefix,?domain"
508
-
509
-# migrate subscribers with no serweb support
510
-migrate_table ${dst_db}.subscriber \
511
-	"id,username,domain,password,ha1,ha1b,rpid" \
512
-	${src_db}.subscriber \
513
-	"?id,?username,?domain,?password,?ha1,?ha1b,?rpid"
514
-
515
-if [ "$HAS_EXTRA" = "yes" ] ; then
516
-	migrate_table ${dst_db}.cpl \
517
-		"id,username,domain,cpl_xml,cpl_bin" \
518
-		${src_db}.cpl \
519
-		"?id,?username,?domain,?cpl_xml,?cpl_bin"
520
-
521
-	migrate_table ${dst_db}.siptrace \
522
-		"id,date,callid,traced_user,msg,method,status,fromip,toip,\
523
-		fromtag,direction" \
524
-		${src_db}.siptrace \
525
-		"?id,?date,?callid,?traced_user,?msg,?method,?status,?fromip,?toip,\
526
-		?fromtag,?direction"
527
-
528
-	migrate_table ${dst_db}.imc_rooms \
529
-		"id,name,domain,flag" \
530
-		${src_db}.imc_rooms \
531
-		"?id,?name,?domain,?flag"
532
-
533
-	migrate_table ${dst_db}.imc_members \
534
-		"id,username,domain,room,flag" \
535
-		${src_db}.im_members \
536
-		"?id,?username,?domain,?room,?flag"
537
-fi
538
-
539
-
540
-}  #end migrate_db()
541
-
542 376
 
543 377
 export DBROOTPW
544 378
 if [ "$#" -ne 0 ] && [ "$DBROOTPW" = "" ]; then