34
34
use Phalcon \Migrations \Version \ItemCollection as VersionCollection ;
35
35
use Phalcon \Migrations \Version \ItemInterface ;
36
36
use Phalcon \Text ;
37
+ use Throwable ;
38
+
39
+ use function get_called_class ;
37
40
38
41
/**
39
42
* Migrations of DML y DDL over databases
@@ -538,13 +541,13 @@ public function morphTable(string $tableName, array $definition): void
538
541
if (!isset ($ localFields [$ fieldName ])) {
539
542
try {
540
543
self ::$ connection ->addColumn ($ tableName , $ tableSchema , $ column );
541
- } catch (\ Throwable $ exception ) {
544
+ } catch (Throwable $ exception ) {
542
545
throw new RuntimeException (
543
546
sprintf (
544
547
"Failed to add column '%s' in table '%s'. In '%s' migration. DB error: %s " ,
545
548
$ column ->getName (),
546
549
$ tableName ,
547
- \ get_called_class (),
550
+ get_called_class (),
548
551
$ exception ->getMessage ()
549
552
)
550
553
);
@@ -577,13 +580,13 @@ public function morphTable(string $tableName, array $definition): void
577
580
if ($ changed === true ) {
578
581
try {
579
582
self ::$ connection ->modifyColumn ($ tableName , $ tableSchema , $ column , $ column );
580
- } catch (\ Throwable $ exception ) {
583
+ } catch (Throwable $ exception ) {
581
584
throw new RuntimeException (
582
585
sprintf (
583
586
"Failed to modify column '%s' in table '%s'. In '%s' migration. DB error: %s " ,
584
587
$ column ->getName (),
585
588
$ tableName ,
586
- \ get_called_class (),
589
+ get_called_class (),
587
590
$ exception ->getMessage ()
588
591
)
589
592
);
@@ -598,13 +601,13 @@ public function morphTable(string $tableName, array $definition): void
598
601
* TODO: Check, why schemaName is empty string.
599
602
*/
600
603
self ::$ connection ->dropColumn ($ tableName , '' , $ fieldName );
601
- } catch (\ Throwable $ exception ) {
604
+ } catch (Throwable $ exception ) {
602
605
throw new RuntimeException (
603
606
sprintf (
604
607
"Failed to drop column '%s' in table '%s'. In '%s' migration. DB error: %s " ,
605
608
$ fieldName ,
606
609
$ tableName ,
607
- \ get_called_class (),
610
+ get_called_class (),
608
611
$ exception ->getMessage ()
609
612
)
610
613
);
@@ -614,12 +617,12 @@ public function morphTable(string $tableName, array $definition): void
614
617
} else {
615
618
try {
616
619
self ::$ connection ->createTable ($ tableName , $ tableSchema , $ definition );
617
- } catch (\ Throwable $ exception ) {
620
+ } catch (Throwable $ exception ) {
618
621
throw new RuntimeException (
619
622
sprintf (
620
623
"Failed to create table '%s'. In '%s' migration. DB error: %s " ,
621
624
$ tableName ,
622
- \ get_called_class (),
625
+ get_called_class (),
623
626
$ exception ->getMessage ()
624
627
)
625
628
);
@@ -659,13 +662,13 @@ public function morphTable(string $tableName, array $definition): void
659
662
$ schemaName ,
660
663
$ tableReference
661
664
);
662
- } catch (\ Throwable $ exception ) {
665
+ } catch (Throwable $ exception ) {
663
666
throw new RuntimeException (
664
667
sprintf (
665
668
"Failed to add foreign key '%s' in '%s'. In '%s' migration. DB error: %s " ,
666
669
$ tableReference ->getName (),
667
670
$ tableName ,
668
- \ get_called_class (),
671
+ get_called_class (),
669
672
$ exception ->getMessage ()
670
673
)
671
674
);
@@ -725,13 +728,13 @@ public function morphTable(string $tableName, array $definition): void
725
728
$ schemaName ,
726
729
$ tableReference ->getName ()
727
730
);
728
- } catch (\ Throwable $ exception ) {
731
+ } catch (Throwable $ exception ) {
729
732
throw new RuntimeException (
730
733
sprintf (
731
734
"Failed to drop foreign key '%s' in '%s'. In '%s' migration. DB error: %s " ,
732
735
$ tableReference ->getName (),
733
736
$ tableName ,
734
- \ get_called_class (),
737
+ get_called_class (),
735
738
$ exception ->getMessage ()
736
739
)
737
740
);
@@ -743,13 +746,13 @@ public function morphTable(string $tableName, array $definition): void
743
746
$ schemaName ,
744
747
$ tableReference
745
748
);
746
- } catch (\ Throwable $ exception ) {
749
+ } catch (Throwable $ exception ) {
747
750
throw new RuntimeException (
748
751
sprintf (
749
752
"Failed to add foreign key '%s' in '%s'. In '%s' migration. DB error: %s " ,
750
753
$ tableReference ->getName (),
751
754
$ tableName ,
752
- \ get_called_class (),
755
+ get_called_class (),
753
756
$ exception ->getMessage ()
754
757
)
755
758
);
@@ -764,13 +767,13 @@ public function morphTable(string $tableName, array $definition): void
764
767
* TODO: Check, why schemaName is empty string.
765
768
*/
766
769
self ::$ connection ->dropForeignKey ($ tableName , '' , $ referenceName );
767
- } catch (\ Throwable $ exception ) {
770
+ } catch (Throwable $ exception ) {
768
771
throw new RuntimeException (
769
772
sprintf (
770
773
"Failed to drop foreign key '%s' in '%s'. In '%s' migration. DB error: %s " ,
771
774
$ referenceName ,
772
775
$ tableName ,
773
- \ get_called_class (),
776
+ get_called_class (),
774
777
$ exception ->getMessage ()
775
778
)
776
779
);
@@ -996,13 +999,13 @@ private function addPrimaryKey(string $tableName, string $schemaName, IndexInter
996
999
{
997
1000
try {
998
1001
self ::$ connection ->addPrimaryKey ($ tableName , $ schemaName , $ index );
999
- } catch (\ Throwable $ exception ) {
1002
+ } catch (Throwable $ exception ) {
1000
1003
throw new RuntimeException (
1001
1004
sprintf (
1002
1005
"Failed to add primary key '%s' in '%s'. In '%s' migration. DB error: %s " ,
1003
1006
$ index ->getName (),
1004
1007
$ tableName ,
1005
- \ get_called_class (),
1008
+ get_called_class (),
1006
1009
$ exception ->getMessage ()
1007
1010
)
1008
1011
);
@@ -1018,12 +1021,12 @@ private function dropPrimaryKey(string $tableName, string $schemaName): void
1018
1021
{
1019
1022
try {
1020
1023
self ::$ connection ->dropPrimaryKey ($ tableName , $ schemaName );
1021
- } catch (\ Throwable $ exception ) {
1024
+ } catch (Throwable $ exception ) {
1022
1025
throw new RuntimeException (
1023
1026
sprintf (
1024
1027
"Failed to drop primary key in '%s'. In '%s' migration. DB error: %s " ,
1025
1028
$ tableName ,
1026
- \ get_called_class (),
1029
+ get_called_class (),
1027
1030
$ exception ->getMessage ()
1028
1031
)
1029
1032
);
@@ -1040,13 +1043,13 @@ private function addIndex(string $tableName, string $schemaName, IndexInterface
1040
1043
{
1041
1044
try {
1042
1045
self ::$ connection ->addIndex ($ tableName , $ schemaName , $ indexName );
1043
- } catch (\ Throwable $ exception ) {
1046
+ } catch (Throwable $ exception ) {
1044
1047
throw new RuntimeException (
1045
1048
sprintf (
1046
1049
"Failed to add index '%s' in '%s'. In '%s' migration. DB error: %s " ,
1047
1050
$ indexName ->getName (),
1048
1051
$ tableName ,
1049
- \ get_called_class (),
1052
+ get_called_class (),
1050
1053
$ exception ->getMessage ()
1051
1054
)
1052
1055
);
@@ -1063,13 +1066,13 @@ private function dropIndex(string $tableName, string $schemaName, string $indexN
1063
1066
{
1064
1067
try {
1065
1068
self ::$ connection ->dropIndex ($ tableName , $ schemaName , $ indexName );
1066
- } catch (\ Throwable $ exception ) {
1069
+ } catch (Throwable $ exception ) {
1067
1070
throw new RuntimeException (
1068
1071
sprintf (
1069
1072
"Failed to drop index '%s' in '%s'. In '%s' migration. DB error: %s " ,
1070
1073
$ indexName ,
1071
1074
$ tableName ,
1072
- \ get_called_class (),
1075
+ get_called_class (),
1073
1076
$ exception ->getMessage ()
1074
1077
)
1075
1078
);
0 commit comments