gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] tools dead_column_cleaner.rb,NONE,1.1


From: tom
Subject: [Gforge-commits] tools dead_column_cleaner.rb,NONE,1.1
Date: Tue, 10 Feb 2004 15:30:16 -0600

Update of /cvsroot/gforge/tools
In directory db.perdue.net:/tmp/cvs-serv23216

Added Files:
        dead_column_cleaner.rb 
Log Message:
A small utility to clean out the 'dead' columns from various GForge tables

--- NEW FILE: dead_column_cleaner.rb ---
#!/usr/local/bin/ruby

USER_STR = "-U gforge gforge"

tables = []
`psql -t -q #{USER_STR} -c "\dt"`.split("\n").each {|line|
        tables << line.split("|")[1].delete(" ")
}

tables.each {|t| 
        puts "Checking table " + t
        cmd = "psql -t -q #{USER_STR} -c "
        cmd += "\"\\d #{t}\""
        `#{cmd}`.split("\n").each {|line|
                col = line.split("|")[0].delete(" ")
                if col.index("dead") == 0
                        puts "Removing column " + col + " from table " + t
                        cmd = "psql #{USER_STR} -c "
                        cmd += "\"alter table #{t} drop column #{col}\""
                        puts cmd
                        `#{cmd}`
                end
        }       
}

`vacuumdb #{USER_STR}`





reply via email to

[Prev in Thread] Current Thread [Next in Thread]