diff options
-rwxr-xr-x | dia2pg.rb | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -128,11 +128,13 @@ class Table end r << "CREATE TABLE #{name}\n(\n" pk = [] + idx = [] uq = { :all=>[] } @attributes.each do |attr| sql = attr.to_sql next if sql.nil? r << sql + idx << attr.real_name if attr.index? pk << attr.real_name if attr.primary_key if attr.unique and not attr.primary_key if attr.comment=~/U./ @@ -148,6 +150,7 @@ class Table r.sub!(/,\n$/,"\n") r << ")\nWITH (\n OIDS=#{@opts.oids ? 'TRUE' : 'FALSE'}\n);\n" r << "ALTER TABLE #{name} OWNER TO #{@opts.user};\n" + idx.each do |attr| r << "CREATE INDEX ON #{name} (#{attr});\n" end r end # @@ -174,6 +177,11 @@ class Attribute @type=~/foreign/ end # + def index? + return false if @comment.nil? + @comment=~/index=1/ + end + # def no_rename? return false if @comment.nil? @comment=~/no_rename=1/ |