dbupdate_3.3.php: added foreign key tbl_phrasentext_sprache_fkey on

system.tbl_phrasentext.sprache that references to public.tbl_sprache.sprache
This commit is contained in:
Paolo
2017-08-29 15:05:00 +02:00
parent c826e76e8f
commit e908be8021
+21 -6
View File
@@ -282,25 +282,25 @@ if(!$result = @$db->db_query("SELECT 1 FROM system.tbl_udf LIMIT 1"))
echo '<strong>system.tbl_udf: '.$db->db_last_error().'</strong><br>';
else
echo '<br>system.tbl_udf table created';
$qry = 'COMMENT ON COLUMN system.tbl_udf.schema IS \'Schema of the table\';';
if(!$db->db_query($qry))
echo '<strong>Adding comment to system.tbl_udf.schema: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Added comment to system.tbl_udf.schema';
$qry = 'COMMENT ON COLUMN system.tbl_udf.table IS \'Table name\';';
if(!$db->db_query($qry))
echo '<strong>Adding comment to system.tbl_udf.table: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Added comment to system.tbl_udf.table';
$qry = 'COMMENT ON COLUMN system.tbl_udf.jsons IS \'JSON schema\';';
if(!$db->db_query($qry))
echo '<strong>Adding comment to system.tbl_udf.jsons: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Added comment to system.tbl_udf.jsons';
$qry = 'GRANT SELECT ON TABLE system.tbl_udf TO web;';
if(!$db->db_query($qry))
echo '<strong>system.tbl_udf: '.$db->db_last_error().'</strong><br>';
@@ -381,13 +381,28 @@ if(!$result = @$db->db_query("SELECT design_uid FROM public.tbl_service LIMIT 1;
ALTER TABLE public.tbl_service ADD CONSTRAINT fk_tbl_service_design_uid FOREIGN KEY (design_uid) REFERENCES public.tbl_benutzer (uid) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE public.tbl_service ADD CONSTRAINT fk_tbl_service_betrieb_uid FOREIGN KEY (betrieb_uid) REFERENCES public.tbl_benutzer (uid) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE public.tbl_service ADD CONSTRAINT fk_tbl_service_operativ_uid FOREIGN KEY (operativ_uid) REFERENCES public.tbl_benutzer (uid) ON DELETE RESTRICT ON UPDATE CASCADE;";
if(!$db->db_query($qry))
echo '<strong>public.tbl_service: '.$db->db_last_error().'</strong><br>';
else
echo '<br>public.tbl_service: Spalten design_uid,betrieb_uid,operativ_uid hinzugefuegt!<br>';
}
// FOREIGN KEY tbl_phrasentext_sprache_fkey: system.tbl_phrasentext.sprache references public.tbl_sprache.sprache
if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_phrasentext_sprache_fkey'"))
{
if ($db->db_num_rows($result) == 0)
{
error_log("ok");
$qry = "ALTER TABLE system.tbl_phrasentext ADD CONSTRAINT tbl_phrasentext_sprache_fkey FOREIGN KEY (sprache) REFERENCES public.tbl_sprache(sprache) ON UPDATE CASCADE ON DELETE RESTRICT;";
if (!$db->db_query($qry))
echo '<strong>system.tbl_phrasentext: '.$db->db_last_error().'</strong><br>';
else
echo '<br>system.tbl_phrasentext: added foreign key on column sprache referenced to public.tbl_sprache(sprache)';
}
}
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
@@ -726,4 +741,4 @@ if (!$result=@$db->db_query($sql_query))
}
if($error==false)
echo '<br>Gegenpruefung fehlerfrei';
?>
?>