From e908be80210784dda8989644fa32ed3ac23d30a8 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 29 Aug 2017 15:05:00 +0200 Subject: [PATCH] dbupdate_3.3.php: added foreign key tbl_phrasentext_sprache_fkey on system.tbl_phrasentext.sprache that references to public.tbl_sprache.sprache --- system/dbupdate_3.3.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 4faef4719..3e4f19771 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -282,25 +282,25 @@ if(!$result = @$db->db_query("SELECT 1 FROM system.tbl_udf LIMIT 1")) echo 'system.tbl_udf: '.$db->db_last_error().'
'; else echo '
system.tbl_udf table created'; - + $qry = 'COMMENT ON COLUMN system.tbl_udf.schema IS \'Schema of the table\';'; if(!$db->db_query($qry)) echo 'Adding comment to system.tbl_udf.schema: '.$db->db_last_error().'
'; else echo '
Added comment to system.tbl_udf.schema'; - + $qry = 'COMMENT ON COLUMN system.tbl_udf.table IS \'Table name\';'; if(!$db->db_query($qry)) echo 'Adding comment to system.tbl_udf.table: '.$db->db_last_error().'
'; else echo '
Added comment to system.tbl_udf.table'; - + $qry = 'COMMENT ON COLUMN system.tbl_udf.jsons IS \'JSON schema\';'; if(!$db->db_query($qry)) echo 'Adding comment to system.tbl_udf.jsons: '.$db->db_last_error().'
'; else echo '
Added comment to system.tbl_udf.jsons'; - + $qry = 'GRANT SELECT ON TABLE system.tbl_udf TO web;'; if(!$db->db_query($qry)) echo 'system.tbl_udf: '.$db->db_last_error().'
'; @@ -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 'public.tbl_service: '.$db->db_last_error().'
'; else echo '
public.tbl_service: Spalten design_uid,betrieb_uid,operativ_uid hinzugefuegt!
'; } +// 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 'system.tbl_phrasentext: '.$db->db_last_error().'
'; + else + echo '
system.tbl_phrasentext: added foreign key on column sprache referenced to public.tbl_sprache(sprache)'; + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -726,4 +741,4 @@ if (!$result=@$db->db_query($sql_query)) } if($error==false) echo '
Gegenpruefung fehlerfrei'; -?> \ No newline at end of file +?>