summaryrefslogtreecommitdiffstats
path: root/create/schema/gen.pl
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-05 13:20:58 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-05 13:20:58 +0000
commite99897ec33423ccabd32fd15256dafbe65616668 (patch)
tree3e96e2a0b922919323f870d3655d9b5311bd7850 /create/schema/gen.pl
parent8da7e95733b4278a3a469983e1ef9a241328a027 (diff)
downloadzabbix-e99897ec33423ccabd32fd15256dafbe65616668.tar.gz
zabbix-e99897ec33423ccabd32fd15256dafbe65616668.tar.xz
zabbix-e99897ec33423ccabd32fd15256dafbe65616668.zip
- [DEV-105] Database changes
git-svn-id: svn://svn.zabbix.com/trunk@5441 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'create/schema/gen.pl')
-rwxr-xr-xcreate/schema/gen.pl22
1 files changed, 18 insertions, 4 deletions
diff --git a/create/schema/gen.pl b/create/schema/gen.pl
index 9e5d609f..647a66b6 100755
--- a/create/schema/gen.pl
+++ b/create/schema/gen.pl
@@ -184,7 +184,7 @@ sub newstate
if($new eq "field") { print ",\n" }
}
case "index" {
- if($output{"type"} eq "sql" && $new eq "table") { print "\n"; }
+ if($output{"type"} eq "sql" && $new eq "table") { print ""; }
if($output{"type"} eq "code" && $new eq "table") { print ",\n\t\t{0}\n\t\t}\n\t},\n"; }
}
case "table" {
@@ -223,7 +223,14 @@ sub process_table
{
$pkey="";
}
- print "CREATE TABLE $table_name (\n";
+
+ $ifexists = "";
+ if ($output{"database"} eq "sqlite")
+ {
+ $ifexists = "IF EXISTS ";
+ }
+
+ print "CREATE TABLE $ifexists$table_name (\n";
}
}
@@ -295,13 +302,20 @@ sub process_index
}
($name,$fields)=split(/\|/, $line,2);
+
+ $ifexists = "";
+ if($output{"database"} eq "sqlite")
+ {
+ $ifexists = "IF EXISTS ";
+ }
+
if($unique == 1)
{
- print "CREATE UNIQUE INDEX ${table_name}_$name\ on $table_name ($fields);\n";
+ print "CREATE UNIQUE INDEX $ifexists${table_name}_$name\ on $table_name ($fields);\n";
}
else
{
- print "CREATE INDEX ${table_name}_$name\ on $table_name ($fields);\n";
+ print "CREATE INDEX $ifexists${table_name}_$name\ on $table_name ($fields);\n";
}
}