@@ -282,6 +282,8 @@ function setup_env() {
282
282
283
283
# if table changes are inside release, we have to call special-functionalities
284
284
table_changes=" FALSE"
285
+ table_array=()
286
+ table_set=()
285
287
286
288
# folder outside git repo
287
289
depotpath=" $( pwd) /$DEPOT_PATH /$branch "
@@ -620,13 +622,29 @@ function write_install_schemas(){
620
622
entries=(" ${targetpath} /db/${schema} /.hooks/pre/${path} " /* .* )
621
623
for entry in " ${entries[@]} " ; do
622
624
file=$( basename " ${entry} " )
625
+ file_ext=${file#* .}
626
+
627
+ if [[ " ${file_ext} " == " tables.sql" ]]; then
628
+
629
+ if [ ${# table_set[@]} -gt 0 ]; then
630
+ echo " Prompt running .hooks/pre/${path} /${file} with table set" >> " ${target_install_file} "
631
+ for table_item in " ${table_set[@]} "
632
+ do
633
+ echo " Prompt >>> db/${schema} /.hooks/pre/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
634
+ echo " @@.hooks/pre/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
635
+ echo " Prompt <<< db/${schema} /.hooks/pre/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
636
+ done
637
+ echo " Prompt" >> " ${target_install_file} "
638
+ echo " " >> " ${target_install_file} "
639
+ fi
623
640
624
- {
625
- echo " Prompt >>> db/${schema} /.hooks/pre/${path} /${file} "
626
- echo " @@.hooks/pre/${path} /${file} "
627
- echo " Prompt <<< db/${schema} /.hooks/pre/${path} /${file} "
628
- } >> " ${target_install_file} "
629
-
641
+ else
642
+ {
643
+ echo " Prompt >>> db/${schema} /.hooks/pre/${path} /${file} "
644
+ echo " @@.hooks/pre/${path} /${file} "
645
+ echo " Prompt <<< db/${schema} /.hooks/pre/${path} /${file} "
646
+ } >> " ${target_install_file} "
647
+ fi
630
648
done
631
649
632
650
echo " Prompt" >> " ${target_install_file} "
@@ -647,11 +665,16 @@ function write_install_schemas(){
647
665
648
666
for entry in " ${sorted[@]} " ; do
649
667
file=$( basename " ${entry} " )
668
+ file_ext=${file#* .}
650
669
651
670
if [[ " ${path} " == " tables" ]]; then
652
671
skipfile=" FALSE"
653
672
table_changes=" TRUE"
654
673
674
+ # store tablename in array
675
+ table_name=" ${file%% .* } "
676
+ table_array+=( ${table_name} )
677
+
655
678
if [[ " ${mode} " == " patch" ]]; then
656
679
if [[ -d " ${targetpath} /db/${schema} /tables/tables_ddl" ]]; then
657
680
for f in " ${targetpath} /db/${schema} /tables/tables_ddl" /${file%% .* } .* ; do
@@ -670,37 +693,76 @@ function write_install_schemas(){
670
693
echo " Prompt <<< db/${schema} /${path} /${file} " >> " ${target_install_file} "
671
694
fi
672
695
else
673
- echo " Prompt >>> db/${schema} /${path} /${file} " >> " ${target_install_file} "
674
- if [[ " ${path} " == " ddl/pre_tst" ]] && [[ " ${mode} " == " patch" ]]; then
675
- echo " --tst@@${path} /${file} " >> " ${target_install_file} "
676
- elif [[ " ${path} " == " ddl/pre_uat" ]] && [[ " ${mode} " == " patch" ]]; then
677
- echo " --uat@@${path} /${file} " >> " ${target_install_file} "
696
+
697
+ if ([[ " ${path} " == " .hooks/pre" ]] || [[ " ${path} " == " .hooks/post" ]]) && [[ " ${file_ext} " == " tables.sql" ]]; then
698
+
699
+ if [ ${# table_set[@]} -gt 0 ]; then
700
+ echo " Prompt running ${path} /${file} with table set" >> " ${target_install_file} "
701
+ for table_item in " ${table_set[@]} "
702
+ do
703
+ echo " Prompt >>> db/${schema} /${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
704
+ echo " @@${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
705
+ echo " Prompt <<< db/${schema} /${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
706
+ done
707
+ echo " Prompt" >> " ${target_install_file} "
708
+ echo " " >> " ${target_install_file} "
709
+ fi
678
710
else
679
- echo " @@${path} /${file} " >> " ${target_install_file} "
680
- echo " Prompt <<< db/${schema} /${path} /${file} " >> " ${target_install_file} "
711
+
712
+ echo " Prompt >>> db/${schema} /${path} /${file} " >> " ${target_install_file} "
713
+ if [[ " ${path} " == " ddl/pre_tst" ]] && [[ " ${mode} " == " patch" ]]; then
714
+ echo " --tst@@${path} /${file} " >> " ${target_install_file} "
715
+ elif [[ " ${path} " == " ddl/pre_uat" ]] && [[ " ${mode} " == " patch" ]]; then
716
+ echo " --uat@@${path} /${file} " >> " ${target_install_file} "
717
+ else
718
+ echo " @@${path} /${file} " >> " ${target_install_file} "
719
+ echo " Prompt <<< db/${schema} /${path} /${file} " >> " ${target_install_file} "
720
+ fi
721
+
681
722
fi
682
723
fi
683
- done
724
+ done # files in folder (sorted)
725
+
726
+ # union table names
727
+ if [[ " ${path} " == " tables" ]]; then
728
+ # get distinct values of array
729
+ table_set=($( printf " %s\n" " ${table_array[@]} " | sort -u) )
730
+ fi
684
731
685
732
if [[ " ${path} " == " ddl/patch/pre" ]] || [[ " ${path} " == " ddl/patch/pre_tst" ]] || [[ " ${path} " == " ddl/patch/pre_uat" ]]|| [[ " ${path} " == " views" ]]
686
733
then
687
734
echo " WHENEVER SQLERROR EXIT SQL.SQLCODE" >> " ${target_install_file} "
688
735
fi
689
736
690
737
691
-
692
738
# post folder hooks
693
739
echo " Prompt" >> " ${target_install_file} "
694
740
entries=(" ${targetpath} /db/${schema} /.hooks/post/${path} " /* .* )
695
741
for entry in " ${entries[@]} " ; do
696
742
file=$( basename " ${entry} " )
743
+ file_ext=${file#* .}
744
+
745
+ if [[ " ${file_ext} " == " tables.sql" ]]; then
746
+
747
+ if [ ${# table_set[@]} -gt 0 ]; then
748
+ echo " Prompt running .hooks/post/${path} /${file} with table set" >> " ${target_install_file} "
749
+ for table_item in " ${table_set[@]} "
750
+ do
751
+ echo " Prompt >>> db/${schema} /.hooks/post/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
752
+ echo " @@.hooks/post/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
753
+ echo " Prompt <<< db/${schema} /.hooks/post/${path} /${file} ${version} ${mode} ${table_item} .sql" >> " ${target_install_file} "
754
+ done
755
+ echo " Prompt" >> " ${target_install_file} "
756
+ echo " " >> " ${target_install_file} "
757
+ fi
697
758
698
- {
699
- echo " Prompt >>> db/${schema} /.hooks/post/${path} /${file} "
700
- echo " @@.hooks/post/${path} /${file} "
701
- echo " Prompt <<< db/${schema} /.hooks/post/${path} /${file} "
702
- } >> " ${target_install_file} "
703
-
759
+ else
760
+ {
761
+ echo " Prompt >>> db/${schema} /.hooks/post/${path} /${file} "
762
+ echo " @@.hooks/post/${path} /${file} "
763
+ echo " Prompt <<< db/${schema} /.hooks/post/${path} /${file} "
764
+ } >> " ${target_install_file} "
765
+ fi
704
766
done
705
767
706
768
# set scan to off, to make use of vars inside main schema-hooks
@@ -711,8 +773,9 @@ function write_install_schemas(){
711
773
echo " Prompt" >> " ${target_install_file} "
712
774
echo " Prompt" >> " ${target_install_file} "
713
775
echo " " >> " ${target_install_file} "
714
- fi
715
- done # path
776
+
777
+ fi # path exists
778
+ done # paths
716
779
717
780
echo " prompt compiling schema" >> " ${target_install_file} "
718
781
echo " exec dbms_utility.compile_schema(schema => user, compile_all => false);" >> " ${target_install_file} "
0 commit comments