migrations/Version20240905104814.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 Version20240905104814 extends AbstractMigration
  10.     {
  11.         public function getDescription(): string
  12.         {
  13.             return '';
  14.         }
  15.         public function up(Schema $schema): void
  16.         {
  17.             $this->addSql(
  18.                 'ALTER VIEW report_total_or_installments_count AS
  19.     select a.academic_year, a.title, count(a.id) as total
  20.     from (SELECT DISTINCT s.id    AS id,
  21.                           CASE
  22.                               WHEN i.title = \'U cjelosti\' THEN \'Uplata u cjelosti\'
  23.                               ELSE \'Rate\'
  24.                               END AS title,
  25.                           e.academic_year
  26.           FROM students s
  27.                    LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  28.                    LEFT JOIN enrollment_events e ON e.profile_id = p.id
  29.                    LEFT JOIN tuition_installments i ON e.id = i.enrollment_id
  30.           where e.academic_year is not null
  31.             and e.tuition_modality_template_id is not null) a
  32.     group by a.academic_year, a.title;
  33. '
  34.             );
  35.             $this->addSql(
  36.                 'ALTER VIEW report_total_or_installments_amount AS
  37.     select a.academic_year, a.title, sum(a.total) as total
  38.     from (SELECT DISTINCT e.academic_year,
  39.                           CASE
  40.                               WHEN t.title = \'U cjelosti\' THEN \'Uplata u cjelosti\'
  41.                               ELSE \'Rate\'
  42.                               END       AS title,
  43.                           sum(t.amount) as total
  44.           FROM students s
  45.                    LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  46.                    LEFT JOIN enrollment_events e ON e.profile_id = p.id
  47.                    left join tuition_installments t on t.enrollment_id = e.id
  48.           WHERE e.academic_year is not null
  49.             and e.tuition_modality_template_id is not null
  50.             and t.payed_on is not null
  51.           GROUP BY e.academic_year, title) a
  52.     group by a.academic_year, a.title;'
  53.             );
  54.         }
  55.         public function down(Schema $schema): void
  56.         {
  57.             $this->addSql(
  58.                 'ALTER VIEW report_total_or_installments_count AS
  59. select a.academic_year, a.title, count(a.id) as total
  60. from (SELECT DISTINCT s.id    AS id,
  61.                       CASE
  62.                           WHEN ti.title = \'Uplata u cjelosti\' THEN ti.title
  63.                           ELSE \'Rate\'
  64.                           END AS title,
  65.                       e.academic_year
  66.       FROM students s
  67.                LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  68.                LEFT JOIN enrollment_events e ON e.profile_id = p.id
  69.                LEFT JOIN tuition_modality_templates t ON e.tuition_modality_template_id = t.id
  70.                LEFT JOIN tuition_installments_templates ti ON t.id = ti.tuition_modality_template_id
  71.       where e.academic_year is not null  and e.tuition_modality_template_id is not null
  72.       ) a
  73. group by a.academic_year, a.title;
  74. '
  75.             );
  76.             $this->addSql(
  77.                 'ALTER VIEW report_total_or_installments_amount AS
  78. select a.academic_year, a.title, sum(t.amount) as total
  79. from (SELECT DISTINCT e.id,
  80.                       CASE
  81.                           WHEN ti.title = \'Uplata u cjelosti\' THEN ti.title
  82.                           ELSE \'Rate\'
  83.                           END AS title,
  84.                       e.academic_year
  85.       FROM students s
  86.                LEFT JOIN udg_fms.profiles p ON s.id = p.student_id
  87.                LEFT JOIN enrollment_events e ON e.profile_id = p.id
  88.                LEFT JOIN tuition_modality_templates t ON e.tuition_modality_template_id = t.id
  89.                LEFT JOIN tuition_installments_templates ti ON t.id = ti.tuition_modality_template_id
  90.       WHERE e.academic_year is not null  and e.tuition_modality_template_id is not null
  91.       GROUP BY e.id, title) a
  92.          left join tuition_installments t on t.enrollment_id = a.id
  93. where t.payed_on is not null
  94. group by a.academic_year,a.title;'
  95.             );
  96.         }
  97.     }