diff --git a/application/libraries/MigrationLib.php b/application/libraries/MigrationLib.php index 1f0e5c290..92899ebca 100644 --- a/application/libraries/MigrationLib.php +++ b/application/libraries/MigrationLib.php @@ -16,6 +16,8 @@ class MigrationLib extends CI_Migration const ERROR_COLOR = 31; const INFO_COLOR = 33; + const PRINT_QUERY_LEN = 60; + // HTML colors names private $HTML_COLORS = array(31 => "red", 33 => "orange"); // Used to set if the migration process is called via command line or via browser @@ -539,6 +541,10 @@ class MigrationLib extends CI_Migration } } - $this->printInfo("Query correctly executed"); + $this->printInfo( + "Query correctly executed: " . + substr(preg_replace("/\s+/", " ", trim($query)), 0, MigrationLib::PRINT_QUERY_LEN) . + (strlen($query) > MigrationLib::PRINT_QUERY_LEN ? "..." : "") + ); } } \ No newline at end of file diff --git a/application/migrations/015_person_svnr.php b/application/migrations/015_person_svnr.php new file mode 100644 index 000000000..08e7ba541 --- /dev/null +++ b/application/migrations/015_person_svnr.php @@ -0,0 +1,50 @@ +startUP(); + + $this->execQuery("ALTER TABLE public.tbl_person DROP CONSTRAINT chk_person_svnr"); + $this->execQuery( + "ALTER TABLE public.tbl_person + ADD CONSTRAINT chk_person_svnr + CHECK ( + char_length(svnr::text) = 10 OR + char_length(svnr::text) = 12 OR + char_length(svnr::text) = 16 OR + svnr IS NULL + )" + ); + + $this->endUP(); + } + + public function down() + { + $this->startDown(); + + $this->execQuery("ALTER TABLE public.tbl_person DROP CONSTRAINT chk_person_svnr"); + $this->execQuery( + "ALTER TABLE public.tbl_person + ADD CONSTRAINT chk_person_svnr + CHECK ( + char_length(svnr::text) = 10 OR + char_length(svnr::text) = 16 OR + svnr IS NULL + )" + ); + + $this->endDown(); + } +} \ No newline at end of file