summaryrefslogtreecommitdiffstats
path: root/create/schema
diff options
context:
space:
mode:
Diffstat (limited to 'create/schema')
-rwxr-xr-xcreate/schema/gen.pl32
-rw-r--r--create/schema/schema.sql11
2 files changed, 30 insertions, 13 deletions
diff --git a/create/schema/gen.pl b/create/schema/gen.pl
index 21845725..f56081d3 100755
--- a/create/schema/gen.pl
+++ b/create/schema/gen.pl
@@ -40,7 +40,7 @@ local $output;
"t_time" => "integer",
# It does not work for MySQL 3.x and <4.x (4.11?)
# "t_serial" => "serial",
- "t_serial" => "bigint unsigned not null auto_increment unique",
+ "t_serial" => "bigint unsigned",
"t_double" => "double(16,4)",
"t_percentage" => "double(5,2)",
"t_varchar" => "varchar",
@@ -158,7 +158,7 @@ static ZBX_TABLE tables[]={
"t_id" => "bigint",
"t_integer" => "integer",
"t_time" => "integer",
- "t_serial" => "serial",
+ "t_serial" => "integer",
"t_double" => "double(16,4)",
"t_percentage" => "double(5,2)",
"t_varchar" => "varchar",
@@ -178,8 +178,8 @@ sub newstate
switch ($state)
{
case "field" {
- if($output{"type"} eq "sql" && $new eq "index") { print $pkey; }
- if($output{"type"} eq "sql" && $new eq "table") { print $pkey; }
+ if($output{"type"} eq "sql" && $new eq "index") { print "$pkey\n)$output{'table_options'};\n"; }
+ if($output{"type"} eq "sql" && $new eq "table") { print "$pkey\n)$output{'table_options'};\n"; }
if($output{"type"} eq "code" && $new eq "table") { print ",\n\t\t{0}\n\t\t}\n\t},\n"; }
if($new eq "field") { print ",\n" }
}
@@ -197,7 +197,6 @@ sub newstate
sub process_table
{
local $line=$_[0];
- local $tmp;
newstate("table");
($table_name,$pkey,$flags)=split(/\|/, $line,4);
@@ -218,14 +217,12 @@ sub process_table
{
if($pkey ne "")
{
- $pkey=",\n\tPRIMARY KEY ($pkey)\n)";
+ $pkey=",\n\tPRIMARY KEY ($pkey)";
}
else
{
- $pkey="\n)";
+ $pkey="";
}
- $tmp=$output{"table_options"};
- $pkey="$pkey$tmp;\n";
print "CREATE TABLE $table_name (\n";
}
}
@@ -266,7 +263,22 @@ sub process_field
# $default="DEFAULT NULL";
$null="";
}
- print "\t$name\t\t$type_2\t\t$default\t$null";
+
+ $row="\t$name\t\t$type_2\t\t$default\t$null";
+
+ if($type eq "t_serial")
+ {
+ if($output{"database"} eq "sqlite")
+ {
+ $row="$row\tPRIMARY KEY AUTOINCREMENT";
+ $pkey="";
+ }
+ elsif($output{"database"} eq "mysql")
+ {
+ $row="$row\tauto_increment unique";
+ }
+ }
+ print $row;
}
}
diff --git a/create/schema/schema.sql b/create/schema/schema.sql
index d305e5c3..afd7e976 100644
--- a/create/schema/schema.sql
+++ b/create/schema/schema.sql
@@ -178,7 +178,7 @@ FIELD |value |t_double |'0.0000'|NOT NULL |0
INDEX |1 |itemid,clock
TABLE|history_sync|id|ZBX_HISTORY_SYNC
-FIELD |id |t_serial | | |0
+FIELD |id |t_serial | |NOT NULL |0
FIELD |nodeid |t_id |'0' |NOT NULL |0
FIELD |itemid |t_id |'0' |NOT NULL |ZBX_HISTORY_SYNC
FIELD |clock |t_time |'0' |NOT NULL |ZBX_HISTORY_SYNC
@@ -192,7 +192,7 @@ FIELD |value |t_bigint |'0' |NOT NULL |0
INDEX |1 |itemid,clock
TABLE|history_uint_sync|id|ZBX_HISTORY_SYNC
-FIELD |id |t_serial | | |0
+FIELD |id |t_serial | |NOT NULL |0
FIELD |nodeid |t_id |'0' |NOT NULL |0
FIELD |itemid |t_id |'0' |NOT NULL |ZBX_HISTORY_SYNC
FIELD |clock |t_time |'0' |NOT NULL |ZBX_HISTORY_SYNC
@@ -206,7 +206,7 @@ FIELD |value |t_varchar(255) |'' |NOT NULL |0
INDEX |1 |itemid,clock
TABLE|history_str_sync|id|ZBX_HISTORY_SYNC
-FIELD |id |t_serial | | |0
+FIELD |id |t_serial | |NOT NULL |0
FIELD |nodeid |t_id |'0' |NOT NULL |0
FIELD |itemid |t_id |'0' |NOT NULL |ZBX_HISTORY_SYNC
FIELD |clock |t_time |'0' |NOT NULL |ZBX_HISTORY_SYNC
@@ -384,6 +384,11 @@ TABLE|proxies|proxyid|ZBX_SYNC
FIELD |proxyid |t_id |'0' |NOT NULL |0
FIELD |name |t_varchar(64) |'' |NOT NULL |ZBX_SYNC
FIELD |lastaccess |t_integer |'0' |NOT NULL |ZBX_SYNC
+FIELD |history_lastid |t_bigint |'0' |NOT NULL |0
+FIELD |history_uint_lastid|t_bigint |'0' |NOT NULL |0
+FIELD |history_str_lastid|t_bigint |'0' |NOT NULL |0
+FIELD |history_text_lastid|t_bigint |'0' |NOT NULL |0
+FIELD |history_log_lastid|t_bigint |'0' |NOT NULL |0
INDEX |1 |name
TABLE|hosts|hostid|ZBX_SYNC