migrations/Version20241203205251.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20241203205251 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('ALTER VIEW report_total_or_installments_count AS
  18. select a.academic_year AS academic_year, a.title AS title, count(*) AS total
  19. from (SELECT e.academic_year AS academic_year,
  20.              CASE
  21.                  WHEN i.title IN (\'U cjelosti\', \'Uplata u cjelosti\')
  22.                      THEN \'Uplata u cjelosti\'
  23.                  ELSE \'Rate\'
  24.                  END         AS title,
  25.              COUNT(s.id)     AS total
  26.       FROM students s
  27.                LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  28.                LEFT JOIN udg_fms.enrollment_events e ON e.profile_id = p.id
  29.                left join tuition_modality_templates t on e.tuition_modality_template_id = t.id
  30.                LEFT JOIN udg_fms.tuition_installments i ON e.id = i.enrollment_id
  31.       WHERE e.academic_year IS NOT NULL
  32.         AND e.tuition_modality_template_id IS NOT NULL
  33.         AND i.payed_on IS NOT NULL
  34.       GROUP BY e.academic_year,
  35.                CASE
  36.                    WHEN i.title IN (\'U cjelosti\', \'Uplata u cjelosti\')
  37.                        THEN \'Uplata u cjelosti\'
  38.                    ELSE \'Rate\'
  39.                    END,
  40.                s.faculty, s.first_name, s.last_name, p.index_no, p.current_semester, t.title) a
  41. group by a.academic_year, a.title');
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         // this down() migration is auto-generated, please modify it to your needs
  46.         $this->addSql('ALTER VIEW report_total_or_installments_count AS
  47.     select a.academic_year, a.title, count(a.id) as total
  48.     from (SELECT DISTINCT s.id    AS id,
  49.                           CASE
  50.                               WHEN i.title IN (\'U cjelosti\', \'Uplata u cjelosti\')
  51.                      THEN \'Uplata u cjelosti\'
  52.                               ELSE \'Rate\'
  53.                               END AS title,
  54.                           e.academic_year
  55.           FROM students s
  56.                    LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  57.                    LEFT JOIN enrollment_events e ON e.profile_id = p.id
  58.                    LEFT JOIN tuition_installments i ON e.id = i.enrollment_id
  59.           where e.academic_year is not null
  60.             and e.tuition_modality_template_id is not null) a
  61.     group by a.academic_year, a.title;');
  62.     }
  63. }