From dea7eadd9c26c1fae7c2240d46aadff92f9a6702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Jun 2014 10:56:02 +0200 Subject: dia2pg: index=1 -> CREATE INDEX ON table(attr); --- dia2pg.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dia2pg.rb b/dia2pg.rb index 5886637..e00183d 100755 --- a/dia2pg.rb +++ b/dia2pg.rb @@ -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/ -- cgit v1.1-2-g2b99