It is an ongoing nuisance not being able to delete users
The following unix code creates a file with the the database schema showing the tables and fields.
#Using psql Create a list of tables
#Use table list to generate field list for each table
#psql -c “SELECT tablename FROM pg_tables WHERE tablename !~* ‘pg_*’” > tablelist
psql -t -c “select table_name from information_schema.tables where table_schema NOT IN (‘pg_catalog’, ‘information_schema’)” > tablelist
#Use the list to generate the list of fields in each table
for tname in
echo $tname >> dbSchema
psql -c “SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen AS length, a.atttypmod AS length_var, a.attnotnull AS not_null, a.atthasdef as has_default FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = ‘$tname’ AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid ORDER BY a.attnum;”>> dbSchema
The resulting tables show the user id field in 15 tables although a user_id may or may not exist in these tables and the the SQL to remove a specific user_id is not difficult.
I have tried deleting a user ID in these tables and so far so good. Would anyone like to comment about he saftey of this and how we can make it work if there is a problem.