Minor updates for database base declare scripts

This commit is contained in:
Clemens Schwaighofer
2020-03-06 15:28:32 +09:00
parent 899ddc011c
commit ed01d248ec
6 changed files with 27 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ function/set_generic.sql
function/random_string.sql function/random_string.sql
function/set_edit_generic.sql function/set_edit_generic.sql
function/edit_set_access_uid.sql function/edit_set_access_uid.sql
function/edit_log_partition_trigger.sql function/edit_log_partition_insert.sql
# generic tables # generic tables
table/edit_temp_files.sql table/edit_temp_files.sql
table/edit_generic.sql table/edit_generic.sql
@@ -30,7 +30,6 @@ trigger/trg_edit_access_right.sql
trigger/trg_edit_access.sql trigger/trg_edit_access.sql
trigger/trg_edit_access_data.sql trigger/trg_edit_access_data.sql
trigger/trg_edit_access_user.sql trigger/trg_edit_access_user.sql
trigger/trg_edit_generic.sql
trigger/trg_edit_group.sql trigger/trg_edit_group.sql
trigger/trg_edit_language.sql trigger/trg_edit_language.sql
trigger/trg_edit_log.sql trigger/trg_edit_log.sql

View File

@@ -15,22 +15,20 @@ function_name="set_generic";
#sql_path_prep=`echo $sql_path | sed -e "s/\///g"`; #sql_path_prep=`echo $sql_path | sed -e "s/\///g"`;
# goes for each file and strips headers and endings, and creates trigger name # goes for each file and strips headers and endings, and creates trigger name
for name in $sql_path*; for name in $sql_path*; do
do
echo "Wokring on $name"; echo "Wokring on $name";
# strip ending # strip ending
# t_name=`echo $name | sed -e 's/.sql$//g' | sed -e "s/^$sql_path_prep//g" | sed -e 's/\///g'`; # t_name=`echo $name | sed -e 's/.sql$//g' | sed -e "s/^$sql_path_prep//g" | sed -e 's/\///g'`;
t_name=`echo $name | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`; t_name=`echo $name | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`;
# clean all beginnings # clean all beginnings
for prefix in $file_prefix; for prefix in $file_prefix; do
do
prefix=$prefix"_"; prefix=$prefix"_";
t_name=`echo $t_name | sed -e "s/\$prefix//g"`; t_name=`echo $t_name | sed -e "s/\$prefix//g"`;
done; done;
# those tables don't need a trigger # those tables don't need a trigger
# edit_generic # edit_generic
# generic # generic
# copy the trigger template to the target # copy the trigger template to the target
trg_filename=$trigger_path$trigger_prefix"_"$t_name".sql"; trg_filename=$trigger_path$trigger_prefix"_"$t_name".sql";

View File

@@ -14,17 +14,14 @@ file_prefix="trg";
trigger_prefix="trg"; trigger_prefix="trg";
index_prefix="idx"; index_prefix="idx";
for file in `cat ORDER`; for file in `cat ORDER`; do
do if [ -f $file ]; then
if [ -f $file ];
then
# write them into a var, so we can re order them in the other way # write them into a var, so we can re order them in the other way
new_order=$file" "$new_order; new_order=$file" "$new_order;
fi; fi;
done; done;
for file in $new_order; for file in $new_order; do
do
sqltype=`echo $file | egrep "table/"`; sqltype=`echo $file | egrep "table/"`;
trgtype=`echo $file | egrep "trigger/"`; trgtype=`echo $file | egrep "trigger/"`;
idxtype=`echo $file | egrep "index/"`; idxtype=`echo $file | egrep "index/"`;
@@ -32,43 +29,34 @@ do
datatype=`echo $file | egrep "data/"`; datatype=`echo $file | egrep "data/"`;
# remove all around to get table name # remove all around to get table name
t_file=`echo $file | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`; t_file=`echo $file | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`;
for prefix in $file_prefix; for prefix in $file_prefix; do
do
prefix=$prefix"_"; prefix=$prefix"_";
t_file=`echo $t_file | sed -e "s/\$prefix//g"`; t_file=`echo $t_file | sed -e "s/\$prefix//g"`;
done; done;
# copy the trigger template to the target # copy the trigger template to the target
for path in $schemas; for path in $schemas; do
do if [ $sqltype ]; then
if [ $sqltype ];
then
echo "SQL "$path"."$t_file; echo "SQL "$path"."$t_file;
echo "DROP TABLE "$path"."$t_file" CASCADE;" | psql -U $user -h $host $db echo "DROP TABLE "$path"."$t_file" CASCADE;" | psql -U $user -h $host $db
fi; fi;
if [ $trgtype ]; if [ $trgtype ]; then
then
trigger=$trigger_prefix"_"$t_file; trigger=$trigger_prefix"_"$t_file;
echo "TRG $trigger TBL "$path".$t_file"; echo "TRG $trigger TBL "$path".$t_file";
echo "DROP TRIGGER "$path".$trigger ON "$t_file" CASCADE;" | psql -U $user -h $host $db echo "DROP TRIGGER "$path".$trigger ON "$t_file" CASCADE;" | psql -U $user -h $host $db
fi; fi;
if [ $fcttype ]; if [ $fcttype ]; then
then
echo "FCT "$path"."$t_file; echo "FCT "$path"."$t_file;
echo "DROP FUNCTION "$path"."$t_file"();" | psql -U $user -h $host $db echo "DROP FUNCTION "$path"."$t_file"();" | psql -U $user -h $host $db
fi; fi;
if [ $idxtype ]; if [ $idxtype ]; then
then
index=$index_prefix"_"$t_file; index=$index_prefix"_"$t_file;
# echo "IDX "$t_file; # echo "IDX "$t_file;
# echo "DROP INDEX $index ON $t_file;" | psql -U $user -h $host $db # echo "DROP INDEX $index ON $t_file;" | psql -U $user -h $host $db
fi; fi;
if [ $datatype ]; if [ $datatype ]; then
then
echo "DATA "$t_file; echo "DATA "$t_file;
# echo "DROP FUNCTION "$t_file"();" | psql -U $user -h $host $db # echo "DROP FUNCTION "$t_file"();" | psql -U $user -h $host $db
fi; fi;
# psql -U cms_user -h 192.168.12.14 -f $file CMSv2
done; done;
done; done;

View File

@@ -0,0 +1,4 @@
-- DROP TRIGGER trg_set_edit_access_uid ON edit_access;
CREATE TRIGGER trg_set_edit_access_uid
BEFORE INSERT OR UPDATE ON edit_access
FOR EACH ROW EXECUTE PROCEDURE set_edit_access_uid();

View File

@@ -496,7 +496,7 @@ function hideOverlayBox()
*/ */
function ClearCall() function ClearCall()
{ {
$('#actionBox').innerHTML = ''; $('#actionBox').html('');
$('#actionBox').hide(); $('#actionBox').hide();
$('#overlayBox').hide(); $('#overlayBox').hide();
} }

View File

@@ -1234,9 +1234,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
} elseif ($data_array['type'] == 'radio_group' && !isset($_POST[$prfx.$el_name])) { } elseif ($data_array['type'] == 'radio_group' && !isset($_POST[$prfx.$el_name])) {
// radio group and set where one not active // radio group and set where one not active
// $this->debug('edit_error_chk', 'RADIO GROUP'); // $this->debug('edit_error_chk', 'RADIO GROUP');
$row_okay[$_POST[$prfx.$el_name][$i]] = 0; $row_okay[$_POST[$prfx.$el_name][$i] ?? 0] = 0;
$default_wrong[$_POST[$prfx.$el_name][$i]] = 1; $default_wrong[$_POST[$prfx.$el_name][$i] ?? 0] = 1;
$error[$_POST[$prfx.$el_name][$i]] = 1; $error[$_POST[$prfx.$el_name][$i] ?? 0] = 1;
} elseif (isset($_POST[$prfx.$el_name][$i]) && !isset($error[$i])) { } elseif (isset($_POST[$prfx.$el_name][$i]) && !isset($error[$i])) {
// $this->debug('edit_error_chk', '[$i]'); // $this->debug('edit_error_chk', '[$i]');
$element_set[$i] = 1; $element_set[$i] = 1;