# Generated by Django 2.1.3 on 2019-01-20 17:52

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ('hospital', '0001_initial'),
    ]

    operations = [
        migrations.RunSQL(
        """
        CREATE FUNCTION salary(selected_employ_id integer) RETURNS float AS
        $$
            SELECT sum((he.hours / hj.number_hours) * hj.base_salary)
            FROM hospital_employment as he 
            LEFT JOIN hospital_jobposition as hj ON he.position_id = hj.id
            WHERE he.employ_id = selected_employ_id;
        $$ LANGUAGE SQL;""",
        """
        DROP FUNCTION salary(integer);
        """)
    ]
