migrations/Version20241006121120.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 Version20241006121120 extends AbstractMigration
  10.     {
  11.         public function getDescription(): string
  12.         {
  13.             return '';
  14.         }
  15.         public function up(Schema $schema): void
  16.         {
  17.             $this->addSql(
  18.                 'create view report_total_or_installments_amount_per_year_and_student as
  19.     select p.faculty,
  20.            p.index_no,
  21.            p.current_semester                                             as semester,
  22.            concat(s.first_name, \' \', s.last_name)                         as full_name,
  23.            e.academic_year                                                AS academic_year,
  24.            sp.name                                                        as study_program,
  25.            case
  26.                when t.title = \'U cjelosti\' or t.title = \'Uplata u cjelosti\' then \'Uplata u cjelosti\'
  27.                else \'Rate\' end                                            AS payment_type,
  28.            SUM(CASE WHEN t.payed_on IS NOT NULL THEN t.amount ELSE 0 END) AS amount,
  29.            case
  30.                when m.covered = 1 then m.title
  31.                else \'\' end                                                AS sponsored
  32.     from students s
  33.              left join profiles p on s.id = p.student_id
  34.              left join enrollment_events e on e.profile_id = p.id
  35.              left join tuition_modality_templates m on e.tuition_modality_template_id = m.id
  36.              left join tuition_installments t on t.enrollment_id = e.id
  37.              left join study_programmes sp on sp.id = p.study_programme_id
  38.     where e.academic_year is not null
  39.       and e.tuition_modality_template_id is not null
  40.     group by p.faculty, p.index_no, s.first_name, s.last_name, e.academic_year, sp.name, payment_type, sponsored,
  41.              p.current_semester
  42.     order by p.faculty, e.academic_year, sp.name, p.index_no;');
  43.         }
  44.         public function down(Schema $schema): void
  45.         {
  46.             $this->addSql('DROP VIEW report_total_or_installments_amount_per_year_and_student');
  47.         }
  48.     }