diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-06-26 10:56:02 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-06-26 10:56:02 +0200 |
commit | dea7eadd9c26c1fae7c2240d46aadff92f9a6702 (patch) | |
tree | 53d2694c48a3c2ef853f19ed96371a19a33c289a /dia2pg.rb | |
parent | 56f2c559e6f4719a3601c8a34fad8674e67c475f (diff) | |
download | bin-dea7eadd9c26c1fae7c2240d46aadff92f9a6702.zip bin-dea7eadd9c26c1fae7c2240d46aadff92f9a6702.tar.gz |
dia2pg: index=1 -> CREATE INDEX ON table(attr);
Diffstat (limited to 'dia2pg.rb')
-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/ |