#! /bin/bash

for f in `ls ./database_conversion/converted_database`; do
	db=$f
	dir=`basename $f .sqlite`
#	echo $dir
	mkdir ./database_conversion/new_columns/$dir
	new_tables=`echo '.tables' | sqlite3 ./database_conversion/converted_database/$db`
	for t in $new_tables; do
#		echo $t
		echo "pragma table_info($t);" | sqlite3 ./database_conversion/converted_database/$db | awk -F'|' '$5{print $2 "," $5 ","} !$5{print $2 "," "\x27" $5 "\x27" ","}' > ./database_conversion/new_columns/$dir/$t
	done
done

for f in `ls ./database`; do
	db=$f
	dir=`basename $f .sqlite`
#	echo $dir
	mkdir ./database_conversion/old_columns/$dir
	old_tables=`echo '.tables' | sqlite3 ./database/$db`
	for t in $old_tables; do
#		echo $t
		echo "pragma table_info($t);" | sqlite3 ./database/$db | awk -F'|' '{print $2 "," $5 ","}' > ./database_conversion/old_columns/$dir/$t
	done
done

