When you have to export the comments from the database you can use this short snippet to get the schema as markup.
content = ""
database_name = "DATABASE_NAME"
ActiveRecord::Base.connection.tables.each do |table_name|
content << "h5. #{table_name}\n"
rows = ActiveRecord::Base.connection.execute("SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='#{database_name}'
AND table_name='#{table_name}';");
puts rows.to_a.inspect
content << rows.to_a.first.first << "\n"
rows = ActiveRecord::Base.connection.execute("select table_name, column_name, DATA_TYPE, column_comment from INFORMATION_SCHEMA.COLUMNS where 1 AND TABLE_SCHEMA='#{database_name}' AND TABLE_NAME = '#{table_name}'")
rows.each(:as => :hash) do |row|
puts row.inspect
j = [ row["column_name"], row["DATA_TYPE"], row["column_comment"] ]
content << "|#{j.join('|')}|\n"
end
end; ''
puts content
The output should be something like
Table name
table description
column name, type, description
….. the next table