Source
$fkeys .= "${fk_bol}ALTER TABLE${only} `${table_name}` ADD CONSTRAINT `${cname}` FOREIGN KEY (`${name}`) REFERENCES `${fk_table}` (`${fk_field}`)${fk_flags}${fk_eol}\n";
#!/usr/bin/env perl
#
# Zabbix
# Copyright (C) 2001-2023 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
use ;
use ;
use :: ;
my $file = ($0) . "/../src/schema.tmpl"; # name the file
my ($state, %output, $eol, $fk_bol, $fk_eol, $ltab, $pkey, $table_name, $pkey_name);
my ($szcol1, $szcol2, $szcol3, $szcol4, $sequences, $sql_suffix, $triggers);
my ($fkeys, $fkeys_prefix, $fkeys_suffix, $uniq, $delete_cascade);
my %table_types; # for making sure that table types aren't duplicated
my %c = (
"type" => "code",
"database" => "",
"after" => "\t{0}\n};\n\n#undef ZBX_TYPE_LONGTEXT_LEN\n#undef ZBX_TYPE_SHORTTEXT_LEN\n",
"t_bigint" => "ZBX_TYPE_UINT",
"t_text" => "ZBX_TYPE_TEXT",
"t_double" => "ZBX_TYPE_FLOAT",
"t_id" => "ZBX_TYPE_ID",
"t_image" => "ZBX_TYPE_BLOB",
"t_bin" => "ZBX_TYPE_BLOB",
"t_integer" => "ZBX_TYPE_INT",
"t_longtext" => "ZBX_TYPE_LONGTEXT",
"t_nanosec" => "ZBX_TYPE_INT",
"t_serial" => "ZBX_TYPE_UINT",
"t_shorttext" => "ZBX_TYPE_SHORTTEXT",
"t_time" => "ZBX_TYPE_INT",
"t_varchar" => "ZBX_TYPE_CHAR",
"t_cuid" => "ZBX_TYPE_CUID",
);
$c{"before"} = "/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the