diff --git a/db/postgresql/alter_study_groups_formid_17.11.18.sql b/db/postgresql/alter_study_groups_formid_17.11.18.sql
new file mode 100644
index 0000000000000000000000000000000000000000..50ca471de48d8f6c65ddcb6851d769c098f72046
--- /dev/null
+++ b/db/postgresql/alter_study_groups_formid_17.11.18.sql
@@ -0,0 +1,74 @@
+update study_groups set formid=1;
+
+ALTER TABLE public.study_groups ALTER COLUMN formid SET NOT NULL;
+ALTER TABLE public.study_groups ALTER COLUMN formid SET DEFAULT 1;
+
+ALTER TABLE public.study_groups DROP CONSTRAINT study_groups_facultyid_gradeid_groupnum_key;
+ALTER TABLE ONLY study_groups
+  ADD CONSTRAINT study_groups_facultyid_gradeid_groupnum_formid_key UNIQUE (facultyid, gradeid, groupnum, formid);
+
+ALTER TABLE ONLY study_groups
+  ADD CONSTRAINT study_groups_ibfk_4 FOREIGN KEY (formid) REFERENCES study_form(id);
+
+DROP FUNCTION IF EXISTS public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer);
+CREATE OR REPLACE FUNCTION public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer, pformid integer)
+  RETURNS integer
+LANGUAGE plpgsql
+AS $function$
+DECLARE vGroupID INT DEFAULT null;
+        vSpecId INT DEFAULT null;
+        vGroupYear INT DEFAULT null;
+        vIsSpecMatch BOOL DEFAULT null;
+
+BEGIN
+  --select public.creategroup(
+  --	:pgradeid,	-- put the pgradeid parameter value instead of 'pgradeid' (int4)
+  --	:pgroupnum,	-- put the pgroupnum parameter value instead of 'pgroupnum' (int4)
+  --	:pspecname,	-- put the pspecname parameter value instead of 'pspecname' (varchar)
+  --	:pfacultyid,	-- put the pfacultyid parameter value instead of 'pfacultyid' (int4)
+  --	:pyear 	-- put the pyear parameter value instead of 'pyear' (int4)
+  --);
+  -- create specialization vSpecId - UNIQUE (pSpecName,pFacultyID)
+  select specializations.id into vSpecId
+  from specializations
+  where specializations.facultyid=pFacultyID and specializations."name" like pSpecName;
+  if (vSpecId is null) then
+    INSERT INTO specializations (Name, Abbr, FacultyID)
+    VALUES  (pSpecName, NULL, pFacultyID)
+    returning id into vSpecId;
+  end if;
+
+
+  -- create group  vGroupID - UNIQUE (pGradeID, pGroupNum, pFacultyID)
+  select study_groups.id into vGroupID
+  from study_groups
+  where study_groups.gradeid=pgradeID
+        and study_groups.groupnum= pGroupNum
+        and study_groups.facultyid=pFacultyID
+        and study_groups.formid=pFormID;
+  if ( vGroupID  is null) then
+    INSERT INTO study_groups (GradeID, GroupNum, FacultyID, FormID)
+    VALUES (pGradeID, pGroupNum, pFacultyID, pFormID)
+    returning id into  vGroupID ;
+  end if;
+
+
+  SELECT groups_years.groupid, groups_years.specializationid = vSpecId
+  INTO vGroupYear, vIsSpecMatch
+  FROM groups_years
+  WHERE groups_years.groupid = vGroupID AND groups_years."year" = pYear
+  LIMIT 1;
+
+  IF  (vGroupYear is null) THEN
+    INSERT INTO groups_years (GroupID, Year, SpecializationID)
+    VALUES (vGroupID, pYear, vSpecId);
+  ELSEIF NOT vIsSpecMatch THEN
+    RETURN -1;
+  END IF;
+
+  RETURN vGroupID;
+  EXCEPTION
+  when others then
+    RETURN -1;
+END
+$function$;
\ No newline at end of file
diff --git a/db/postgresql/functions.sql b/db/postgresql/functions.sql
index 31a63b85e756d6181135ecf3bc3df9c48ef85677..011eef6357c3f1b0e971083fb5fdfb01176d1e2f 100644
--- a/db/postgresql/functions.sql
+++ b/db/postgresql/functions.sql
@@ -1141,7 +1141,7 @@ BEGIN
 END
 $function$;
 
- CREATE OR REPLACE FUNCTION public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer, pformid fulltime_parttime_evening)
+ CREATE OR REPLACE FUNCTION public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer, pformid integer)
  RETURNS integer
  LANGUAGE plpgsql
  AS $function$
diff --git a/db/postgresql/keys_and_index.sql b/db/postgresql/keys_and_index.sql
index 8885ac9fd029bff6662fbf56a0905c71a68976df..7a7d42e70323b63186b0c5f1e81b231ed06f2762 100644
--- a/db/postgresql/keys_and_index.sql
+++ b/db/postgresql/keys_and_index.sql
@@ -1527,6 +1527,9 @@ ALTER TABLE ONLY study_groups
     ADD CONSTRAINT study_groups_ibfk_3 FOREIGN KEY (facultyid) REFERENCES faculties(id);
 
 
+ALTER TABLE ONLY study_groups
+    ADD CONSTRAINT study_groups_ibfk_4 FOREIGN KEY (formid) REFERENCES study_form(id);
+
 --
 -- TOC entry 2636 (class 2606 OID 46417)
 -- Name: study_plans study_plans_fk_1; Type: FK CONSTRAINT; Schema: public; Owner: -
diff --git a/db/postgresql/tables_and_views.sql b/db/postgresql/tables_and_views.sql
index 50581fecbe97f3912de53a33571742604383bc97..84242288fe285b5161882c58102dca5728d5222e 100644
--- a/db/postgresql/tables_and_views.sql
+++ b/db/postgresql/tables_and_views.sql
@@ -936,7 +936,7 @@ CREATE TABLE study_groups (
     gradeid integer NOT NULL,
     groupnum integer NOT NULL,
     facultyid integer NOT NULL,
-    formid fulltime_parttime_evening DEFAULT 'fulltime' NOT NULL
+    formid integer DEFAULT 1 NOT NULL
 );
 
 
@@ -1294,4 +1294,10 @@ INSERT INTO lesson_types(id, lesson_type) values
 (1, 'лекция'),
 (2, 'лабораторная'),
 (3, 'семинар'),
-(4, 'практикум');
\ No newline at end of file
+(4, 'практикум');
+
+INSERT INTO public.study_form(id, formname) VALUES
+(1, 'очная'),
+(2, 'очно-заочная'),
+(3, 'заочная');
+
diff --git a/db/postgresql/types.sql b/db/postgresql/types.sql
index 7f19bd5532c17efc30a1a5dbeceb2946ff926008..f9dceb22e126f367dbc709dec96040d7422adc06 100644
--- a/db/postgresql/types.sql
+++ b/db/postgresql/types.sql
@@ -152,8 +152,8 @@ CREATE TYPE student_teacher_admin_dean AS ENUM (
 
 CREATE TYPE noukd_norate_full AS ENUM ('noukd', 'norate', 'full');
 
-CREATE TYPE fulltime_parttime_evening AS ENUM (
-    'fulltime',
-    'parttime',
-    'evening'
-);
\ No newline at end of file
+--CREATE TYPE fulltime_parttime_evening AS ENUM (
+--    'fulltime',
+--    'parttime',
+--    'evening'
+--);
\ No newline at end of file
diff --git a/~dev_rating/application/classes/Controller/Api/V0/Student.php b/~dev_rating/application/classes/Controller/Api/V0/Student.php
index 2de2701c7b6bab63689705a6ca3e6b39993304af..8daa5c96b52691d06d338f0f851b1031e688dec5 100644
--- a/~dev_rating/application/classes/Controller/Api/V0/Student.php
+++ b/~dev_rating/application/classes/Controller/Api/V0/Student.php
@@ -143,15 +143,15 @@ class Controller_Api_V0_Student extends Controller_Handler_Api {
 
         switch ($recordBookData->form) {
             case 'Очная':
-                $recordBookData->form = 'fulltime';
+                $recordBookData->form = 1;
                 break;
 
             case 'Очно-заочная':
-                $recordBookData->form = 'parttime';
+                $recordBookData->form = 3;
                 break;
 
             case 'Заочная':
-                $recordBookData->form = 'evening';
+                $recordBookData->form = 2;
                 break;
 
             default: