mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 16:32:20 +00:00
Adaptierungen für checksystem entwicklungteam_id
This commit is contained in:
+48
-51
@@ -5973,104 +5973,100 @@ if(!@$db->db_query("SELECT entwicklungsteam_id FROM bis.tbl_entwicklungsteam LIM
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Neue Spalte entwicklungsteam_id zu Tabelle bis.tbl_entwicklungsteam hinzugefügt';
|
||||
echo '<br>bis.tbl_entwicklungsteam: Neue Spalte entwicklungsteam_id hinzugefügt';
|
||||
}
|
||||
|
||||
//Column entwicklungsteam_id mit Werten befüllen
|
||||
//if($result = @$db->db_query("SELECT entwicklungsteam_id FROM bis.tbl_entwicklungsteam where entwicklungsteam_id is null"))
|
||||
if(!@$db->db_query("SELECT entwicklungsteam_id FROM bis.tbl_entwicklungsteam where entwicklungsteam_id is not null LIMIT 1"))
|
||||
if($result = @$db->db_query("SELECT entwicklungsteam_id FROM bis.tbl_entwicklungsteam where entwicklungsteam_id is not null LIMIT 1"))
|
||||
{
|
||||
|
||||
$qry = 'UPDATE bis.tbl_entwicklungsteam et SET entwicklungsteam_id =
|
||||
(SELECT rownumber FROM (SELECT ROW_NUMBER() OVER (ORDER BY mitarbeiter_uid, studiengang_kz)
|
||||
AS rownumber, t.* FROM bis.tbl_entwicklungsteam t ORDER BY mitarbeiter_uid, studiengang_kz) rn
|
||||
WHERE rn.mitarbeiter_uid = et.mitarbeiter_uid
|
||||
AND rn.studiengang_kz = et.studiengang_kz);
|
||||
';
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Spalte bis.tbl_entwicklungsteam_id mit Werten aufgefüllt';
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Create Sequence bis.tbl_entwicklungsteam
|
||||
if (!@$db->db_query("SELECT * FROM pg_class WHERE relname = 'tbl_entwicklungsteam_entwicklungsteam_id_seq'"))
|
||||
{
|
||||
if ($count = @$db->db_query("SELECT (MAX(entwicklungsteam_id) + 1) AS start FROM bis.tbl_entwicklungsteam"))
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = 'CREATE SEQUENCE bis.tbl_entwicklungsteam_entwicklungsteam_id_seq START ';
|
||||
$qry .= $count;
|
||||
$qry = 'UPDATE bis.tbl_entwicklungsteam et SET entwicklungsteam_id =
|
||||
(SELECT rownumber FROM (SELECT ROW_NUMBER() OVER (ORDER BY mitarbeiter_uid, studiengang_kz)
|
||||
AS rownumber, t.* FROM bis.tbl_entwicklungsteam t ORDER BY mitarbeiter_uid, studiengang_kz) rn
|
||||
WHERE rn.mitarbeiter_uid = et.mitarbeiter_uid
|
||||
AND rn.studiengang_kz = et.studiengang_kz);
|
||||
';
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Sequence bis.tbl_entwicklungsteam_entwicklungsteam_id_seq mit startwert' . $count . ' erstellt';
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>bis.tbl_entwicklungsteam: Spalte bis.tbl_entwicklungsteam_id mit Werten aufgefüllt';
|
||||
}
|
||||
}
|
||||
|
||||
//Add Permission to sequence tbl_entwicklungsteam_entwicklungsteam_id_seq
|
||||
if($result = @$db->db_query("SELECT * FROM information_schema.role_table_grants WHERE table_name='tbl_entwicklungsteam' AND table_schema='bis' AND grantee='web' AND privilege_type='INSERT'"))
|
||||
//Create Sequence bis.tbl_entwicklungsteam and grant Rights
|
||||
if ($result = @$db->db_query("SELECT * FROM pg_class WHERE relname = 'tbl_entwicklungsteam_entwicklungsteam_id_seq'"))
|
||||
{
|
||||
if($db->db_num_rows($result)==0)
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "
|
||||
GRANT SELECT, UPDATE ON bis.tbl_entwicklungsteam_entwicklungsteam_id_seq TO vilesci;
|
||||
GRANT SELECT, UPDATE ON bis.tbl_entwicklungsteam_entwicklungsteam_id_seq TO web;";
|
||||
if ($count = @$db->db_query("SELECT * FROM bis.tbl_entwicklungsteam"))
|
||||
{
|
||||
$count = $db->db_num_rows($count) + 1;
|
||||
$qry = 'CREATE SEQUENCE bis.tbl_entwicklungsteam_entwicklungsteam_id_seq START ';
|
||||
$qry .= $count;
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<br>bis.tbl_entwicklungsteam: Sequence bis.tbl_entwicklungsteam_entwicklungsteam_id_seq mit Startwert ' . $count . ' erstellt';
|
||||
$qry2 = "GRANT SELECT, UPDATE ON bis.tbl_entwicklungsteam_entwicklungsteam_id_seq TO vilesci;
|
||||
GRANT SELECT, UPDATE ON bis.tbl_entwicklungsteam_entwicklungsteam_id_seq TO web;";
|
||||
if(!$db->db_query($qry2))
|
||||
{
|
||||
echo '<strong>bis.tbl_entwicklungsteam_entwicklungsteam_id_seqBerechtigungen: '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<br>bis.tbl_entwicklungsteam: Rechte auf bis.tbl_entwicklungsteam_entwicklungsteam_id_seq fuer web user und vilesci gesetzt ';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>bis.tbl_entwicklungsteam_entwicklungsteam_id_seqBerechtigungen: '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<br>SELECT und UPDATE Rechte auf bis.tbl_entwicklungsteam_entwicklungsteam_id_seq fuer web user und vilesci gesetzt ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Bis.tbl_entwicklungsteam auf NOTNULL setzen
|
||||
if ($result = @$db->db_query("SELECT is_nullable FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tbl_entwicklungsteam' AND column_name = 'entwicklungsteam_id'"))
|
||||
if ($result = @$db->db_query("SELECT is_nullable FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tbl_entwicklungsteam' AND column_name = 'entwicklungsteam_id' and is_nullable = 'NO'"))
|
||||
{
|
||||
if ($result == 'YES')
|
||||
if($db->db_num_rows($result)==0)
|
||||
{
|
||||
$qry = 'ALTER TABLE bis.tbl_entwicklungsteam ALTER COLUMN entwicklungsteam_id SET NOT NULL';
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br> Spalte bis.tbl_entwicklungsteam_id auf NOT NULL gesetzt';
|
||||
echo '<br>bis.tbl_entwicklungsteam: Spalte bis.tbl_entwicklungsteam_id auf NOT NULL gesetzt';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Bis.tbl_entwicklungsteam DEFAULT einstellen
|
||||
if ($result = @$db->db_query("SELECT column_default FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tbl_entwicklungsteam'AND column_name = 'entwicklungsteam_id' and column_default is null"))
|
||||
{
|
||||
if ($result == null)
|
||||
if($db->db_num_rows($result)==1)
|
||||
{
|
||||
$qry = "ALTER TABLE bis.tbl_entwicklungsteam ALTER COLUMN entwicklungsteam_id SET DEFAULT nextval('bis.tbl_entwicklungsteam_entwicklungsteam_id_seq'::regclass);";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong> bis.tbl_entwicklungsteam '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br> Spalte bis.tbl_entwicklungsteam_id: Defaultwert gesetzt';
|
||||
echo '<br> bis.tbl_entwicklungsteam: Defaultwert bei Spalte bis.tbl_entwicklungsteam_id gesetzt';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//DELETE PRIMARY KEY pk_tbl_entwicklungsteam (mitarbeiter_uid, studiengang_kz) entfernen
|
||||
if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'pk_tbl_entwicklungsteam'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 1)
|
||||
if($db->db_num_rows($result)==1)
|
||||
{
|
||||
$qry = "ALTER TABLE bis.tbl_entwicklungsteam DROP CONSTRAINT pk_tbl_entwicklungsteam;";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>bis.tbl_entwicklungsteam: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Spalte bis.tbl_entwicklungsteam: Primary Key pk_tbl_entwicklungsteam entfernt ';
|
||||
echo '<br>bis.tbl_entwicklungsteam: Primary Key pk_tbl_entwicklungsteam (mitarbeiter_uid, studiengang_kz) entfernt ';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6085,12 +6081,13 @@ if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname =
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>sbis.tbl_entwicklungsteam: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Spalte bis.tbl_entwicklungsteam: Primary Key tbl_entwicklungsteam_pk (entwicklungsteam_id) hinzugefügt';
|
||||
echo '<br>bis.tbl_entwicklungsteam: Primary Key tbl_entwicklungsteam_pk (entwicklungsteam_id) hinzugefügt';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user