From 431fedb2eeab529689b34602745ae2bca4921c47 Mon Sep 17 00:00:00 2001 From: Warro Date: Wed, 10 Jul 2019 14:53:08 +0300 Subject: [PATCH 1/6] Fixed rounding in teacher statistics --- .../src/components/TeacherStatisticsTable/index.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/oodikone2-frontend/src/components/TeacherStatisticsTable/index.jsx b/services/oodikone2-frontend/src/components/TeacherStatisticsTable/index.jsx index 5470b876e8..eaacf67253 100644 --- a/services/oodikone2-frontend/src/components/TeacherStatisticsTable/index.jsx +++ b/services/oodikone2-frontend/src/components/TeacherStatisticsTable/index.jsx @@ -35,6 +35,13 @@ class TeacherStatisticsTable extends Component { return direction === 'ascending' ? sorted : sorted.reverse() } + roundStatisticCredits = statistics => ( + statistics.map(s => ({ + ...s, + credits: s.credits.toFixed(2) + })) + ) + render() { const { statistics, onClickFn } = this.props const { selected, direction } = this.state @@ -71,7 +78,7 @@ class TeacherStatisticsTable extends Component { - {this.sortStatistics(statistics).map(({ id, name, credits, passrate, transferred }) => ( + {this.roundStatisticCredits(this.sortStatistics(statistics)).map(({ id, name, credits, passrate, transferred }) => ( onClickFn(id)} style={{ cursor: 'pointer' }} > From ff4afa66492a811afab077e1281f6f906e9b50b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4kinen=20Sasu=20S?= Date: Wed, 10 Jul 2019 15:29:35 +0300 Subject: [PATCH 2/6] npm run scheduleMeta --- services/updater_scheduler/package.json | 1 + services/updater_scheduler/src/schedule_students.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/updater_scheduler/package.json b/services/updater_scheduler/package.json index 9246a33587..21393c816d 100644 --- a/services/updater_scheduler/package.json +++ b/services/updater_scheduler/package.json @@ -10,6 +10,7 @@ "updateStudentNumberList": "node --max_old_space_size=4096 -e 'require(\"./src/student_list_updater.js\").updateStudentNumberList()'", "scheduleActiveStudents": "NATS_CLIENTID=manualActiveSchedule node --max_old_space_size=4096 -e 'require(\"./src/schedule_students.js\").scheduleActiveStudents()'", "scheduleAll": "NATS_CLIENTID=manualAllSchedule node --max_old_space_size=4096 -e 'require(\"./src/schedule_students.js\").scheduleAllStudentsAndMeta()'", + "scheduleMeta": "NATS_CLIENTID=manualAllSchedule node --max_old_space_size=4096 -e 'require(\"./src/schedule_students.js\").scheduleMeta()'", "getOldestTasks": "node --max_old_space_size=4096 -e 'require(\"./src/SchedulingStatistics.js\").getOldestTasks()'" }, "author": "", diff --git a/services/updater_scheduler/src/schedule_students.js b/services/updater_scheduler/src/schedule_students.js index 9dc53e665e..21350b4dee 100644 --- a/services/updater_scheduler/src/schedule_students.js +++ b/services/updater_scheduler/src/schedule_students.js @@ -41,6 +41,11 @@ const scheduleAllStudentsAndMeta = async () => { publish(tasks) } +const scheduleMeta = async () => { + console.log('scheduling meta') + publish([{task: 'meta', type: 'other', active: 'false'}]) +} + const scheduleStudentsByArray = async (studentNumbers) => { try { const tasks = await Schedule.find({ type: 'student', task: { $in: studentNumbers } }) @@ -50,4 +55,4 @@ const scheduleStudentsByArray = async (studentNumbers) => { } return 'scheduled' } -module.exports = { scheduleActiveStudents, scheduleAllStudentsAndMeta, scheduleStudentsByArray } \ No newline at end of file +module.exports = { scheduleActiveStudents, scheduleAllStudentsAndMeta, scheduleStudentsByArray, scheduleMeta } \ No newline at end of file From 4ec3ba2706366be561f62fd1731c39acabf22847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4kinen=20Sasu=20S?= Date: Wed, 10 Jul 2019 15:35:36 +0300 Subject: [PATCH 3/6] HIDE PROGRESS BAR ABOMINATION --- .../src/components/Progressbar/index.jsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/services/oodikone2-frontend/src/components/Progressbar/index.jsx b/services/oodikone2-frontend/src/components/Progressbar/index.jsx index fa251ae3ea..bd7ebeb21d 100644 --- a/services/oodikone2-frontend/src/components/Progressbar/index.jsx +++ b/services/oodikone2-frontend/src/components/Progressbar/index.jsx @@ -34,14 +34,15 @@ const Progressbar = ({ time, pending }) => { startTimer() } - return ( - - ) + return null + // ( + // + // ) } Progressbar.propTypes = { From cab98792dc8e8cdf9714b15d0c0cdcab6846aeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4kinen=20Sasu=20S?= Date: Wed, 10 Jul 2019 15:55:21 +0300 Subject: [PATCH 4/6] perlerkelrek --- .../oodikone2-frontend/src/components/Progressbar/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/oodikone2-frontend/src/components/Progressbar/index.jsx b/services/oodikone2-frontend/src/components/Progressbar/index.jsx index bd7ebeb21d..188cef070b 100644 --- a/services/oodikone2-frontend/src/components/Progressbar/index.jsx +++ b/services/oodikone2-frontend/src/components/Progressbar/index.jsx @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from 'react' -import { Progress } from 'semantic-ui-react' +import { useState, useEffect } from 'react' +// import { Progress } from 'semantic-ui-react' import { number, bool } from 'prop-types' const Progressbar = ({ time, pending }) => { From 51d809135d1fc20241d59d492805334977200d3a Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Wed, 10 Jul 2019 16:01:40 +0300 Subject: [PATCH 5/6] Trunkate broken migrations --- .../20180803_add_language_to_user.js | 12 - .../20180807_add_attainment_date_column.js | 8 - ...0808_01_add_credit_ courseinstace_index.js | 10 - .../20180808_02_add_credit_course_column.js | 19 - ...ate_credit_attainment_and_course_values.js | 15 - .../20180808_04_add_credit_course_index.js | 10 - .../20180903_add_description_to_filters.js | 12 - ...910_01_add_credit_attainment_date_index.js | 10 - ...0_02_add_enrollment_studentnumber_index.js | 10 - ...910_03_add_transfer_studentnumber_index.js | 14 - ...0_04_add_studyright_studentnumber_index.js | 14 - ...20180910_05_drop_courseinstance_columns.js | 7 - ..._drop_courseinstance_and_teacher_tables.js | 8 - ..._07_add_semester_enrollment_date_column.js | 7 - ...20180910_08_create_credit_teacher_table.js | 30 - ...910_09_add_semester_code_fkey_to_credit.js | 14 - ...0_10_add_year_code_and_name_to_semester.js | 8 - .../20180910_11_add_email_to_users.js | 11 - .../20180910_12_create_usage_stats_table.js | 36 - .../20180921_add_new_role_to_users.js | 12 - .../20180924_add_admin_to_database.js | 12 - ...01_add_semester_code_to_missing_credits.js | 15 - ...20181006_02_credit_semestercode_notnull.js | 14 - .../20181101_remove_duplicate_users.js | 48 - .../20181102_unique_username_constraint.js | 9 - .../shared/migrations/20181128_add_indexes.js | 10 - .../20181204_course_start_end_dates.js | 10 - .../20181205_max_course_attainment_date.js | 8 - .../20181207_min_course_attainment_date.js | 8 - .../migrations/20182709_add_is_studymodule.js | 11 - .../20190109_remove_users_from_database.js | 19 - .../20190116_01_create_course_groups.js | 55 - .../20190116_02_create_course_groups.js | 13 - .../20190128_seed_teacher_course_groups.js | 30 - ...90129_00_create_mandatory_courses_table.js | 30 - ...90129_01_seed_medical_mandatory_courses.js | 17 - ...20190129_02_add_course_groups_programme.js | 26 - .../20190220_remove_duplicate_teachers.js | 146 -- .../20190321_create_thesis_courses.js | 35 - .../20190404_01_add_errordata_table.js | 17 - ...02_add_createdAt_updatedAt_to_errordata.js | 9 - .../migrations/20190409_add_gender_info.js | 10 - .../migrations/20190429_course_duplicates.js | 29 - .../20190517_course_duplicates_seed.js | 324 ----- .../20190523_add_mandatory_courses_label.js | 8 - .../shared/migrations/20190527_kone_data.js | 26 - ...20190701_01_add_home_country_to_student.js | 12 - ..._remove_unused_old_country_from_student.js | 9 - .../migrations/20190702_01_drop_old_tables.js | 10 - ...0_transfers_delete_on_studyright_delete.js | 17 - ...=> 20190710_00_delete_me_after_release.js} | 5 +- .../20190710_01_trunkate_migrations.js | 1237 +++++++++++++++++ 52 files changed, 1241 insertions(+), 1255 deletions(-) delete mode 100644 services/backend/shared/migrations/20180803_add_language_to_user.js delete mode 100644 services/backend/shared/migrations/20180807_add_attainment_date_column.js delete mode 100644 services/backend/shared/migrations/20180808_01_add_credit_ courseinstace_index.js delete mode 100644 services/backend/shared/migrations/20180808_02_add_credit_course_column.js delete mode 100644 services/backend/shared/migrations/20180808_03_update_credit_attainment_and_course_values.js delete mode 100644 services/backend/shared/migrations/20180808_04_add_credit_course_index.js delete mode 100644 services/backend/shared/migrations/20180903_add_description_to_filters.js delete mode 100644 services/backend/shared/migrations/20180910_01_add_credit_attainment_date_index.js delete mode 100644 services/backend/shared/migrations/20180910_02_add_enrollment_studentnumber_index.js delete mode 100644 services/backend/shared/migrations/20180910_03_add_transfer_studentnumber_index.js delete mode 100644 services/backend/shared/migrations/20180910_04_add_studyright_studentnumber_index.js delete mode 100644 services/backend/shared/migrations/20180910_05_drop_courseinstance_columns.js delete mode 100644 services/backend/shared/migrations/20180910_06_drop_courseinstance_and_teacher_tables.js delete mode 100644 services/backend/shared/migrations/20180910_07_add_semester_enrollment_date_column.js delete mode 100644 services/backend/shared/migrations/20180910_08_create_credit_teacher_table.js delete mode 100644 services/backend/shared/migrations/20180910_09_add_semester_code_fkey_to_credit.js delete mode 100644 services/backend/shared/migrations/20180910_10_add_year_code_and_name_to_semester.js delete mode 100644 services/backend/shared/migrations/20180910_11_add_email_to_users.js delete mode 100644 services/backend/shared/migrations/20180910_12_create_usage_stats_table.js delete mode 100644 services/backend/shared/migrations/20180921_add_new_role_to_users.js delete mode 100644 services/backend/shared/migrations/20180924_add_admin_to_database.js delete mode 100644 services/backend/shared/migrations/20181006_01_add_semester_code_to_missing_credits.js delete mode 100644 services/backend/shared/migrations/20181006_02_credit_semestercode_notnull.js delete mode 100644 services/backend/shared/migrations/20181101_remove_duplicate_users.js delete mode 100644 services/backend/shared/migrations/20181102_unique_username_constraint.js delete mode 100644 services/backend/shared/migrations/20181128_add_indexes.js delete mode 100644 services/backend/shared/migrations/20181204_course_start_end_dates.js delete mode 100644 services/backend/shared/migrations/20181205_max_course_attainment_date.js delete mode 100644 services/backend/shared/migrations/20181207_min_course_attainment_date.js delete mode 100644 services/backend/shared/migrations/20182709_add_is_studymodule.js delete mode 100644 services/backend/shared/migrations/20190109_remove_users_from_database.js delete mode 100644 services/backend/shared/migrations/20190116_01_create_course_groups.js delete mode 100644 services/backend/shared/migrations/20190116_02_create_course_groups.js delete mode 100644 services/backend/shared/migrations/20190128_seed_teacher_course_groups.js delete mode 100644 services/backend/shared/migrations/20190129_00_create_mandatory_courses_table.js delete mode 100644 services/backend/shared/migrations/20190129_01_seed_medical_mandatory_courses.js delete mode 100644 services/backend/shared/migrations/20190129_02_add_course_groups_programme.js delete mode 100644 services/backend/shared/migrations/20190220_remove_duplicate_teachers.js delete mode 100644 services/backend/shared/migrations/20190321_create_thesis_courses.js delete mode 100644 services/backend/shared/migrations/20190404_01_add_errordata_table.js delete mode 100644 services/backend/shared/migrations/20190404_02_add_createdAt_updatedAt_to_errordata.js delete mode 100644 services/backend/shared/migrations/20190409_add_gender_info.js delete mode 100644 services/backend/shared/migrations/20190429_course_duplicates.js delete mode 100644 services/backend/shared/migrations/20190517_course_duplicates_seed.js delete mode 100644 services/backend/shared/migrations/20190523_add_mandatory_courses_label.js delete mode 100644 services/backend/shared/migrations/20190527_kone_data.js delete mode 100644 services/backend/shared/migrations/20190701_01_add_home_country_to_student.js delete mode 100644 services/backend/shared/migrations/20190701_02_remove_unused_old_country_from_student.js delete mode 100644 services/backend/shared/migrations/20190702_01_drop_old_tables.js delete mode 100644 services/backend/shared/migrations/20190705_00_transfers_delete_on_studyright_delete.js rename services/backend/shared/migrations/{20190702_02_drop_schema_kone.js => 20190710_00_delete_me_after_release.js} (54%) create mode 100644 services/backend/shared/migrations/20190710_01_trunkate_migrations.js diff --git a/services/backend/shared/migrations/20180803_add_language_to_user.js b/services/backend/shared/migrations/20180803_add_language_to_user.js deleted file mode 100644 index 9e8ee4fbc3..0000000000 --- a/services/backend/shared/migrations/20180803_add_language_to_user.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('users', 'language', - { - type: Sequelize.STRING, - defaultValue: 'fi' - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('users', 'language') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180807_add_attainment_date_column.js b/services/backend/shared/migrations/20180807_add_attainment_date_column.js deleted file mode 100644 index 2ca88249c2..0000000000 --- a/services/backend/shared/migrations/20180807_add_attainment_date_column.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('credit', 'attainment_date', { type: Sequelize.DATE }) - }, - down: async (queryInterface) => { - queryInterface.removeColumn('credit', 'attainment_date') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180808_01_add_credit_ courseinstace_index.js b/services/backend/shared/migrations/20180808_01_add_credit_ courseinstace_index.js deleted file mode 100644 index 16a671dba1..0000000000 --- a/services/backend/shared/migrations/20180808_01_add_credit_ courseinstace_index.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - queryInterface.addIndex('credit', { - fields: ['courseinstance_id'], - name: 'credit_courseinstance_id' - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180808_02_add_credit_course_column.js b/services/backend/shared/migrations/20180808_02_add_credit_course_column.js deleted file mode 100644 index 97a72f371a..0000000000 --- a/services/backend/shared/migrations/20180808_02_add_credit_course_column.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn( - 'credit', - 'course_code', - { - type: Sequelize.STRING, - references: { - model: 'course', - key: 'code', - foreignKey: 'credit_course_fkey' - }, - } - ) - }, - down: async (queryInterface) => { - await queryInterface.removeColumn('credit', 'course_code') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180808_03_update_credit_attainment_and_course_values.js b/services/backend/shared/migrations/20180808_03_update_credit_attainment_and_course_values.js deleted file mode 100644 index 4c8374c347..0000000000 --- a/services/backend/shared/migrations/20180808_03_update_credit_attainment_and_course_values.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.sequelize.query(` - UPDATE credit - SET - attainment_date = ci.coursedate, - course_code = ci.course_code - FROM courseinstance ci - WHERE ci.id = credit.courseinstance_id - ; - `) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180808_04_add_credit_course_index.js b/services/backend/shared/migrations/20180808_04_add_credit_course_index.js deleted file mode 100644 index 43697def51..0000000000 --- a/services/backend/shared/migrations/20180808_04_add_credit_course_index.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.addIndex('credit', { - fields: ['course_code'], - name: 'credit_course_code' - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180903_add_description_to_filters.js b/services/backend/shared/migrations/20180903_add_description_to_filters.js deleted file mode 100644 index 4c0326e00b..0000000000 --- a/services/backend/shared/migrations/20180903_add_description_to_filters.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('filters', 'description', - { - type: Sequelize.STRING, - defaultValue: '' - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('filters', 'description') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_01_add_credit_attainment_date_index.js b/services/backend/shared/migrations/20180910_01_add_credit_attainment_date_index.js deleted file mode 100644 index 8c67e0bb06..0000000000 --- a/services/backend/shared/migrations/20180910_01_add_credit_attainment_date_index.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.addIndex('credit', { - fields: ['attainment_date'], - name: 'credit_attainment_date' - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_02_add_enrollment_studentnumber_index.js b/services/backend/shared/migrations/20180910_02_add_enrollment_studentnumber_index.js deleted file mode 100644 index df461a18fd..0000000000 --- a/services/backend/shared/migrations/20180910_02_add_enrollment_studentnumber_index.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.addIndex('semester_enrollments', { - fields: ['studentnumber'], - name: 'semester_enrollment_studentnumber' - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_03_add_transfer_studentnumber_index.js b/services/backend/shared/migrations/20180910_03_add_transfer_studentnumber_index.js deleted file mode 100644 index 321a8cbc22..0000000000 --- a/services/backend/shared/migrations/20180910_03_add_transfer_studentnumber_index.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - try { - await queryInterface.addIndex('transfers', { - fields: ['studentnumber'], - name: 'transfers_studentnumber' - }) - } catch (e) { - console.log('transfers_studentnumber index in table transfers already existed') - } - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_04_add_studyright_studentnumber_index.js b/services/backend/shared/migrations/20180910_04_add_studyright_studentnumber_index.js deleted file mode 100644 index 00b2ed1820..0000000000 --- a/services/backend/shared/migrations/20180910_04_add_studyright_studentnumber_index.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - try { - await queryInterface.addIndex('studyright', { - fields: ['student_studentnumber'], - name: 'studyright_student_studentnumber' - }) - } catch (e) { - console.log('studyright_student_studentnumber index in table studyright already existed') - } - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_05_drop_courseinstance_columns.js b/services/backend/shared/migrations/20180910_05_drop_courseinstance_columns.js deleted file mode 100644 index de87ea04b0..0000000000 --- a/services/backend/shared/migrations/20180910_05_drop_courseinstance_columns.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.removeColumn('credit', 'courseinstance_id') - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_06_drop_courseinstance_and_teacher_tables.js b/services/backend/shared/migrations/20180910_06_drop_courseinstance_and_teacher_tables.js deleted file mode 100644 index 27637b1c5b..0000000000 --- a/services/backend/shared/migrations/20180910_06_drop_courseinstance_and_teacher_tables.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.dropTable('courseteacher') - await queryInterface.dropTable('courseinstance') - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_07_add_semester_enrollment_date_column.js b/services/backend/shared/migrations/20180910_07_add_semester_enrollment_date_column.js deleted file mode 100644 index 2c1b338cb9..0000000000 --- a/services/backend/shared/migrations/20180910_07_add_semester_enrollment_date_column.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('semester_enrollments', 'enrollment_date', { type: Sequelize.DATE }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_08_create_credit_teacher_table.js b/services/backend/shared/migrations/20180910_08_create_credit_teacher_table.js deleted file mode 100644 index b468c391ef..0000000000 --- a/services/backend/shared/migrations/20180910_08_create_credit_teacher_table.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('credit_teachers', { - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - }, - credit_id: { - type: Sequelize.STRING, - primaryKey: true, - references: { - model: 'credit', - key: 'id' - } - }, - teacher_id: { - type: Sequelize.STRING, - primaryKey: true, - references: { - model: 'teacher', - key: 'id' - } - } - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_09_add_semester_code_fkey_to_credit.js b/services/backend/shared/migrations/20180910_09_add_semester_code_fkey_to_credit.js deleted file mode 100644 index 027b51571c..0000000000 --- a/services/backend/shared/migrations/20180910_09_add_semester_code_fkey_to_credit.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('credit', 'semestercode', { - type: Sequelize.INTEGER, - references: { - model: 'semesters', - key: 'semestercode' - } - } - ) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_10_add_year_code_and_name_to_semester.js b/services/backend/shared/migrations/20180910_10_add_year_code_and_name_to_semester.js deleted file mode 100644 index cf85737b77..0000000000 --- a/services/backend/shared/migrations/20180910_10_add_year_code_and_name_to_semester.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('semesters', 'yearcode', { type: Sequelize.INTEGER }) - await queryInterface.addColumn('semesters', 'yearname', { type: Sequelize.STRING }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_11_add_email_to_users.js b/services/backend/shared/migrations/20180910_11_add_email_to_users.js deleted file mode 100644 index 3dd4350d7f..0000000000 --- a/services/backend/shared/migrations/20180910_11_add_email_to_users.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('users', 'email', - { - type: Sequelize.STRING - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('users', 'email') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180910_12_create_usage_stats_table.js b/services/backend/shared/migrations/20180910_12_create_usage_stats_table.js deleted file mode 100644 index c010e31b54..0000000000 --- a/services/backend/shared/migrations/20180910_12_create_usage_stats_table.js +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('usage_statistics', { - id: { - type: Sequelize.STRING, - primaryKey: true, - }, - username: { - type: Sequelize.STRING - }, - name: { - type: Sequelize.STRING - }, - time: { - type: Sequelize.INTEGER - }, - admin: { - type: Sequelize.BOOLEAN - }, - method: { - type: Sequelize.STRING - }, - URL: { - type: Sequelize.STRING - }, - status: { - type: Sequelize.INTEGER - }, - data: { - type: Sequelize.JSONB - }, - }) - }, - down: async () => { - } -} diff --git a/services/backend/shared/migrations/20180921_add_new_role_to_users.js b/services/backend/shared/migrations/20180921_add_new_role_to_users.js deleted file mode 100644 index 1129ad49d1..0000000000 --- a/services/backend/shared/migrations/20180921_add_new_role_to_users.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('users', 'czar', - { - type: Sequelize.BOOLEAN, - defaultValue: false - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('users', 'czar') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20180924_add_admin_to_database.js b/services/backend/shared/migrations/20180924_add_admin_to_database.js deleted file mode 100644 index cb2faf5b24..0000000000 --- a/services/backend/shared/migrations/20180924_add_admin_to_database.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('users', 'admin', - { - type: Sequelize.BOOLEAN, - defaultValue: false - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('users', 'admin') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20181006_01_add_semester_code_to_missing_credits.js b/services/backend/shared/migrations/20181006_01_add_semester_code_to_missing_credits.js deleted file mode 100644 index a1dad5ac56..0000000000 --- a/services/backend/shared/migrations/20181006_01_add_semester_code_to_missing_credits.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - return queryInterface.sequelize.query(` - UPDATE credit - SET - semestercode = semesters.semestercode - FROM semesters - WHERE credit.semestercode is null - AND credit.attainment_date BETWEEN semesters.startdate AND semesters.enddate - ; -`) - }, - down: () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20181006_02_credit_semestercode_notnull.js b/services/backend/shared/migrations/20181006_02_credit_semestercode_notnull.js deleted file mode 100644 index b705fd5551..0000000000 --- a/services/backend/shared/migrations/20181006_02_credit_semestercode_notnull.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.changeColumn( - 'credit', - 'semestercode', - { - type: Sequelize.INTEGER, - allowNull: false - } - ) - }, - down: () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20181101_remove_duplicate_users.js b/services/backend/shared/migrations/20181101_remove_duplicate_users.js deleted file mode 100644 index 0900221660..0000000000 --- a/services/backend/shared/migrations/20181101_remove_duplicate_users.js +++ /dev/null @@ -1,48 +0,0 @@ -// Commented out because it uses User table definition which doesnt exist. -// It would be best to avoid using services and use plain SQL instead - -// const { User } = require('../../models/index') -// const users = require('../../services/users') - -// const uniques = async () => { -// const duplicates = {} -// const primary = {} -// const dbusers = await User.findAll() -// for (let dbuser of dbusers) { -// const { username, id } = dbuser -// if (!primary[username]) { -// primary[username] = id -// } else { -// const alternatives = duplicates[username] || [] -// duplicates[username] = alternatives.concat(id) -// } -// } -// return { primary, duplicates} -// } - -// const setElementsToPrimary = async (primary) => { -// for (let [username, uid] of Object.entries(primary)) { -// const elements = await users.getUserElementDetails(username) -// const codes = elements.map(e => e.code) -// await users.enableElementDetails(uid, codes) -// } -// } - -// const deleteDuplicates = async (duplicates) => { -// for (let codes of Object.values(duplicates)) { -// for (let uid of codes) { -// const user = await User.findById(uid) -// await user.destroy() -// } -// } -// } - -// module.exports = { -// up: async () => { -// const { primary, duplicates } = await uniques() -// await setElementsToPrimary(primary) -// await deleteDuplicates(duplicates) -// }, -// down: () => { -// } -// } diff --git a/services/backend/shared/migrations/20181102_unique_username_constraint.js b/services/backend/shared/migrations/20181102_unique_username_constraint.js deleted file mode 100644 index 96bc63f4bd..0000000000 --- a/services/backend/shared/migrations/20181102_unique_username_constraint.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - return queryInterface.addConstraint('users', ['username'], { - type: 'unique' - }) - }, - down: () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20181128_add_indexes.js b/services/backend/shared/migrations/20181128_add_indexes.js deleted file mode 100644 index ca758134ae..0000000000 --- a/services/backend/shared/migrations/20181128_add_indexes.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.addIndex('credit_teachers', ['teacher_id']) - await queryInterface.addIndex('credit_teachers', ['credit_id']) - }, - down: async (queryInterface) => { - await queryInterface.removeIndex('credit_teachers', ['teacher_id']) - await queryInterface.removeIndex('credit_teachers', ['credit_id']) - } -} diff --git a/services/backend/shared/migrations/20181204_course_start_end_dates.js b/services/backend/shared/migrations/20181204_course_start_end_dates.js deleted file mode 100644 index 421c8c0f73..0000000000 --- a/services/backend/shared/migrations/20181204_course_start_end_dates.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('course', 'startdate', { type: Sequelize.DATE }) - await queryInterface.addColumn('course', 'enddate', { type: Sequelize.DATE }) - }, - down: async (queryInterface) => { - await queryInterface.removeColumn('course', 'startdate') - await queryInterface.removeColumn('enddate', 'enddate') - } -} diff --git a/services/backend/shared/migrations/20181205_max_course_attainment_date.js b/services/backend/shared/migrations/20181205_max_course_attainment_date.js deleted file mode 100644 index abcfb4868f..0000000000 --- a/services/backend/shared/migrations/20181205_max_course_attainment_date.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('course', 'max_attainment_date', { type: Sequelize.DATE }) - }, - down: async (queryInterface) => { - await queryInterface.removeColumn('course', 'max_attainment_date') - } -} diff --git a/services/backend/shared/migrations/20181207_min_course_attainment_date.js b/services/backend/shared/migrations/20181207_min_course_attainment_date.js deleted file mode 100644 index 4a10d82967..0000000000 --- a/services/backend/shared/migrations/20181207_min_course_attainment_date.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('course', 'min_attainment_date', { type: Sequelize.DATE }) - }, - down: async (queryInterface) => { - await queryInterface.removeColumn('course', 'min_attainment_date') - } -} diff --git a/services/backend/shared/migrations/20182709_add_is_studymodule.js b/services/backend/shared/migrations/20182709_add_is_studymodule.js deleted file mode 100644 index 880d83710a..0000000000 --- a/services/backend/shared/migrations/20182709_add_is_studymodule.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.addColumn('credit', 'isStudyModule', - { - type: Sequelize.BOOLEAN - }) - }, - down: (queryInterface) => { - return queryInterface.removeColumn('credit', 'isStudyModule') - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190109_remove_users_from_database.js b/services/backend/shared/migrations/20190109_remove_users_from_database.js deleted file mode 100644 index 527641eef8..0000000000 --- a/services/backend/shared/migrations/20190109_remove_users_from_database.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - up: async (queryInterface) => { - await queryInterface.dropTable('users', { - force: true, - cascade: false, - }) - await queryInterface.dropTable('user_elementdetails', { - force: true, - cascade: false, - }) - await queryInterface.dropTable('user_unit', { - force: true, - cascade: false, - }) - - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190116_01_create_course_groups.js b/services/backend/shared/migrations/20190116_01_create_course_groups.js deleted file mode 100644 index 11874a0440..0000000000 --- a/services/backend/shared/migrations/20190116_01_create_course_groups.js +++ /dev/null @@ -1,55 +0,0 @@ - - -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('course_groups', - { - id: { - primaryKey: true, - type: Sequelize.BIGINT, - autoIncrement: true - }, - name: { - type: Sequelize.STRING, - unique: true - }, - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - } - }) - await queryInterface.createTable('teacher_course_group', - { - id: { - primaryKey: true, - type: Sequelize.BIGINT, - autoIncrement: true - }, - teacher_id: { - type: Sequelize.STRING, - references: { - model: 'teacher', - key: 'id' - } - - }, - course_group_id: { - type: Sequelize.BIGINT, - references: { - model: 'course_groups', - key: 'id' - } - }, - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - } - }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190116_02_create_course_groups.js b/services/backend/shared/migrations/20190116_02_create_course_groups.js deleted file mode 100644 index e9765bced1..0000000000 --- a/services/backend/shared/migrations/20190116_02_create_course_groups.js +++ /dev/null @@ -1,13 +0,0 @@ -const { Teacher, CourseGroup } = require('../../models') -module.exports = { - up: async () => { - Teacher.associate = models => { - Teacher.belongsToMany(models.CourseGroup, { through: 'teacher_course_group' }) - } - CourseGroup.associate = models => { - CourseGroup.belongsToMany(models.Teacher, { through: 'teacher_course_group' }) - } - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190128_seed_teacher_course_groups.js b/services/backend/shared/migrations/20190128_seed_teacher_course_groups.js deleted file mode 100644 index 5a69a7b429..0000000000 --- a/services/backend/shared/migrations/20190128_seed_teacher_course_groups.js +++ /dev/null @@ -1,30 +0,0 @@ -const { teacherStudyGroups } = require('../data/teacher_course_groups') - -module.exports = { - up: async queryInterface => { - await queryInterface.bulkDelete( - 'teacher_course_group', - {} - ) - teacherStudyGroups.forEach(async association => { - await queryInterface.sequelize.query( - ` -INSERT INTO teacher_course_group (teacher_id, course_group_id) -SELECT :teacher_id, id FROM course_groups WHERE name = :course_group_name - `, - { - replacements: { - teacher_id: association.teacher_id, - course_group_name: association.course_group_name - } - } - ) - }) - }, - down: async queryInterface => { - await queryInterface.bulkDelete( - 'teacher_course_group', - {} - ) - } -} diff --git a/services/backend/shared/migrations/20190129_00_create_mandatory_courses_table.js b/services/backend/shared/migrations/20190129_00_create_mandatory_courses_table.js deleted file mode 100644 index a56ed7482f..0000000000 --- a/services/backend/shared/migrations/20190129_00_create_mandatory_courses_table.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('mandatory_courses', - { - id: { - primaryKey: true, - type: Sequelize.BIGINT, - autoIncrement: true - }, - course_code: { - type: Sequelize.STRING, - references: { - model: 'course', - key: 'code' - } - }, - studyprogramme_id: { - type: Sequelize.STRING, - }, - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - } - }) }, - down: queryInterface => { - queryInterface.dropTable('mandatory_courses') - } -} diff --git a/services/backend/shared/migrations/20190129_01_seed_medical_mandatory_courses.js b/services/backend/shared/migrations/20190129_01_seed_medical_mandatory_courses.js deleted file mode 100644 index 8bf110367b..0000000000 --- a/services/backend/shared/migrations/20190129_01_seed_medical_mandatory_courses.js +++ /dev/null @@ -1,17 +0,0 @@ -const mandatoryMedical = require('../data/medicalcodes') -module.exports = { - up: async queryInterface => { - await queryInterface.bulkInsert( - 'mandatory_courses', - mandatoryMedical - ) - }, - down: async queryInterface => { - await queryInterface.bulkDelete( - 'mandatory_courses', - { - studyprogramme_id: 'MH30_001' - } - ) - } -} diff --git a/services/backend/shared/migrations/20190129_02_add_course_groups_programme.js b/services/backend/shared/migrations/20190129_02_add_course_groups_programme.js deleted file mode 100644 index 33358f2f04..0000000000 --- a/services/backend/shared/migrations/20190129_02_add_course_groups_programme.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn( - 'course_groups', - 'programmeid', - { - type: Sequelize.STRING, - defaultValue: 'KH60_001', - references: { - model: 'element_details', - key: 'code' - } - } - ) - await queryInterface.changeColumn('course_groups', 'programmeid', { - type: Sequelize.STRING, - defaultValue: null, - }) - }, - down: async (queryInterface) => { - await queryInterface.removeColumn( - 'course_groups', - 'programmeid' - ) - } -} diff --git a/services/backend/shared/migrations/20190220_remove_duplicate_teachers.js b/services/backend/shared/migrations/20190220_remove_duplicate_teachers.js deleted file mode 100644 index fe6c27e1d9..0000000000 --- a/services/backend/shared/migrations/20190220_remove_duplicate_teachers.js +++ /dev/null @@ -1,146 +0,0 @@ -const doMigration = async sequelize => { - const findDuplicates = () => sequelize.query(` - SELECT t1.id - FROM teacher t1 - INNER JOIN teacher t2 - ON t2.id = 9||t1.id - ;`, { - type: sequelize.QueryTypes.SELECT - }).map(({ id }) => id) - - const removeCreditsFromTeacher = (teacher) => sequelize.query(` - DELETE FROM credit_teachers - WHERE teacher_id = ? - ;`, { - type: sequelize.QueryTypes.DELETE, - replacements: [teacher] - }) - - const findMissingDuplicates = () => sequelize.query(` - SELECT 9||t3.id AS id, t3.code AS code, t3.name AS name - FROM teacher t3 - WHERE 9||t3.id IN ( - SELECT 9||t1.id - FROM teacher t1 - WHERE t1.id NOT LIKE '9%' - EXCEPT - SELECT t2.id - FROM teacher t2 - WHERE t2.id LIKE '9%' - ) - ;`, { - type: sequelize.QueryTypes.SELECT - }) - - const insertTeacher = ({ id, code, name }) => sequelize.query(` - INSERT INTO teacher (id, code, name) VALUES (?, ?, ?) - ;`, { - type: sequelize.QueryTypes.INSERT, - replacements: [id, code, name] - }) - - const findOldCodeCreditTeachers = () => sequelize.query(` - SELECT DISTINCT(teacher_id) AS id - FROM credit_teachers - WHERE teacher_id NOT LIKE '9%' - ;`, { - type: sequelize.QueryTypes.SELECT - }).map(({ id }) => id) - - const updateCreditsForTeacher = teacher => sequelize.query(` - UPDATE credit_teachers - SET teacher_id = ? - WHERE teacher_id = ? - ;`, { - type: sequelize.QueryTypes.UPDATE, - replacements: [`9${teacher}`, teacher] - }) - - const findOldCourseGroupTeachers = () => sequelize.query(` - SELECT teacher_id - FROM teacher_course_group - WHERE teacher_id NOT LIKE '9%' - ;`, { - type: sequelize.QueryTypes.SELECT - }).map(({ teacher_id }) => teacher_id) - - const updateCourseGroupsForTeacher = teacher => sequelize.query(` - UPDATE teacher_course_group - SET teacher_id = ? - WHERE teacher_id = ? - ;`, { - type: sequelize.QueryTypes.UPDATE, - replacements: [`9${teacher}`, teacher] - }) - - const findTeachersWithOldCode = () => sequelize.query(` - SELECT id - FROM teacher - WHERE id NOT LIKE '9%' - ;`, { - type: sequelize.QueryTypes.SELECT - }).map(({ id }) => id) - - const deleteTeacher = id => sequelize.query(` - DELETE FROM teacher - WHERE id = ? - `, { - type: sequelize.QueryTypes.DELETE, - replacements: [id] - }) - - const removeCreditsFromDuplicates = async () => { - const duplicates = await findDuplicates() - console.log('deleting credits from duplicate teachers') - for (let [i, dupid] of duplicates.entries()) { - !(i % 100) && console.log(`deleted credits: ${i} / ${duplicates.length}`) - await removeCreditsFromTeacher(dupid) - } - } - - const createMissingDuplicateTeachers = async () => { - const teachers = await findMissingDuplicates() - for (let [i, teacher] of teachers.entries()) { - !(i % 100) && console.log(`missing duplicates created: ${i} / ${teachers.length}`) - await insertTeacher(teacher) - } - } - - const updateMissingCreditsToNewCodes = async () => { - const codes = await findOldCodeCreditTeachers() - for (let [i, teacherid] of codes.entries()) { - !(i % 100) && console.log(`old teacher id credits updated: ${i} / ${codes.length}`) - await updateCreditsForTeacher(teacherid) - } - } - - const updateCourseGroupsToNewCodes = async () => { - const codes = await findOldCourseGroupTeachers() - for (let [i, teacherid] of codes.entries()) { - !(i % 100) && console.log(`old course group ids updated: ${i} / ${codes.length}`) - await updateCourseGroupsForTeacher(teacherid) - } - } - - const removeTeachersWithOldCode = async () => { - const codes = await findTeachersWithOldCode() - for (let [i, teacherid] of codes.entries()) { - !(i % 100) && console.log(`old teacher ids removed: ${i} / ${codes.length}`) - await deleteTeacher(teacherid) - } - } - - await removeCreditsFromDuplicates() - await createMissingDuplicateTeachers() - await updateMissingCreditsToNewCodes() - await updateCourseGroupsToNewCodes() - await removeTeachersWithOldCode() -} - -module.exports = { - up: async (queryInterface) => { - const { sequelize } = queryInterface - await doMigration(sequelize) - }, - down: async () => {} -} diff --git a/services/backend/shared/migrations/20190321_create_thesis_courses.js b/services/backend/shared/migrations/20190321_create_thesis_courses.js deleted file mode 100644 index 5f26557e92..0000000000 --- a/services/backend/shared/migrations/20190321_create_thesis_courses.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('thesis_courses', { - programmeCode: { - primaryKey: true, - type: Sequelize.STRING, - references: { - model: 'element_details', - key: 'code' - } - }, - courseCode: { - primaryKey: true, - type: Sequelize.STRING, - references: { - model: 'course', - key: 'code' - } - }, - thesisType: { - type: Sequelize.ENUM(['BACHELOR', 'MASTER']) - }, - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - } - }) - }, - down: queryInterface => { - queryInterface.dropTable('thesis_courses') - } -} - \ No newline at end of file diff --git a/services/backend/shared/migrations/20190404_01_add_errordata_table.js b/services/backend/shared/migrations/20190404_01_add_errordata_table.js deleted file mode 100644 index f4bcd9bc3d..0000000000 --- a/services/backend/shared/migrations/20190404_01_add_errordata_table.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('error_data', { - id: { - primaryKey: true, - type: Sequelize.STRING, - }, - data: { - type: Sequelize.JSONB - } - }) - }, - down: queryInterface => { - queryInterface.dropTable('error_data') - } -} diff --git a/services/backend/shared/migrations/20190404_02_add_createdAt_updatedAt_to_errordata.js b/services/backend/shared/migrations/20190404_02_add_createdAt_updatedAt_to_errordata.js deleted file mode 100644 index 91409c97cc..0000000000 --- a/services/backend/shared/migrations/20190404_02_add_createdAt_updatedAt_to_errordata.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('error_data', 'createdAt', { type: Sequelize.DATE }) - await queryInterface.addColumn('error_data', 'updatedAt', { type: Sequelize.DATE }) - - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190409_add_gender_info.js b/services/backend/shared/migrations/20190409_add_gender_info.js deleted file mode 100644 index a552002145..0000000000 --- a/services/backend/shared/migrations/20190409_add_gender_info.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('student', 'gender_code', { type: Sequelize.INTEGER }) - await queryInterface.addColumn('student', 'gender_fi', { type: Sequelize.STRING }) - await queryInterface.addColumn('student', 'gender_sv', { type: Sequelize.STRING }) - await queryInterface.addColumn('student', 'gender_en', { type: Sequelize.STRING }) - }, - down: async () => { - } -} \ No newline at end of file diff --git a/services/backend/shared/migrations/20190429_course_duplicates.js b/services/backend/shared/migrations/20190429_course_duplicates.js deleted file mode 100644 index 7f318a551e..0000000000 --- a/services/backend/shared/migrations/20190429_course_duplicates.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('course_duplicates', { - groupid: { - allowNull: false, - type: Sequelize.INTEGER, - }, - coursecode: { - allowNull: false, - primaryKey: true, - type: Sequelize.STRING, - references: { - model: 'course', - key: 'code' - } - }, - createdAt: { - type: Sequelize.DATE - }, - updatedAt: { - type: Sequelize.DATE - } - }) - }, - - down: queryInterface => { - queryInterface.dropTable('course_duplicates') - } -} diff --git a/services/backend/shared/migrations/20190517_course_duplicates_seed.js b/services/backend/shared/migrations/20190517_course_duplicates_seed.js deleted file mode 100644 index a2b31c7f7e..0000000000 --- a/services/backend/shared/migrations/20190517_course_duplicates_seed.js +++ /dev/null @@ -1,324 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.sequelize.query('DELETE FROM course_duplicates') - await queryInterface.bulkInsert('course_duplicates', rows.map(e => ({ groupid: e[0], coursecode: e[1], createdAt: new Date(), updatedAt: new Date() }))) - }, - - down: () => { - } -} - -const rows = [ -['1', '50031'], -['1', '30300'], -['2', '53112'], -['2', '530217'], -['3', '55306'], -['3', '55077'], -['4', '55328'], -['4', '55055'], -['5', '55521'], -['5', '55056'], -['6', '57084'], -['6', '50000'], -['7', '57595'], -['7', '530146'], -['8', '65122'], -['8', '64162'], -['9', '68207'], -['9', '68166'], -['10', '78134'], -['10', '57714'], -['14', '530148'], -['14', '300123'], -['12', '90093'], -['12', '3750501'], -['13', '90096'], -['13', '3750502'], -['19', 'TKT20002'], -['19', '582104'], -['15', '582221'], -['15', '58160'], -['16', '590190'], -['16', '50099'], -['17', '770270'], -['17', '770044'], -['18', '992993'], -['18', '99299'], -['63', '99501Mat-lu'], -['20', 'TKT20001'], -['20', '58131'], -['21', 'TKT20010'], -['21', '58161'], -['22', 'TKT10005'], -['22', '581305'], -['23', 'TKT10004'], -['23', '581328'], -['24', 'TKT20006'], -['24', '581259'], -['25', 'TKT20007'], -['25', '581260'], -['26', 'TKT20005'], -['26', '582206'], -['27', 'MAT11001'], -['27', '57033'], -['28', 'TKT50003'], -['28', '581324'], -['29', 'TKT10002'], -['29', '581325'], -['30', 'TKT10001'], -['30', '582102'], -['31', 'TKT10003'], -['31', '582103'], -['32', 'TKT20004'], -['32', '582202'], -['33', 'TKT20011'], -['33', '582203'], -['34', 'MAT11002'], -['34', '57043'], -['35', 'MAT21014'], -['35', '57160'], -['36', 'TKT21015'], -['36', '582335'], -['37', 'TKT20003'], -['37', '582219'], -['38', 'TKT21002'], -['38', '582733'], -['39', 'MAT21001'], -['39', '57047'], -['40', 'MAT11003'], -['40', '57116'], -['41', 'DATA15001'], -['41', '582216'], -['42', 'MAT21015'], -['42', '57161'], -['43', 'MAT11004'], -['43', '57117'], -['56', 'FYS1001'], -['45', 'TKT50002'], -['45', '582506'], -['46', 'TKT20013'], -['46', '582204'], -['47', 'TKT50001'], -['47', '582505'], -['48', 'TKT21001'], -['48', '582482'], -['49', 'CSM14101'], -['49', '581358'], -['50', 'CSM14203'], -['50', '581362'], -['51', 'FYS4012'], -['51', '53905'], -['52', 'CSM14105'], -['52', '581360'], -['53', 'KEK101'], -['53', '55052'], -['54', 'KEK223'], -['54', '55059'], -['55', 'MAT21003'], -['55', '57121'], -['56', '530281'], -['58', 'CSM13202'], -['57', 'MAT21020'], -['57', '57122'], -['58', '582749'], -['44', 'FYS2041'], -['59', 'ON-160'], -['59', '200017'], -['60', 'MAT21012'], -['60', '57044'], -['61', 'MAT21007'], -['61', '57101'], -['62', 'MAT21013'], -['62', '57048'], -['44', '53861'], -['14', '80088'], -['14', '582514'], -['65', 'KEK103'], -['65', '55053'], -['80', '200251_WasaT'], -['80', '200251'], -['91', 'KK-ENMALU1'], -['91', 'KK-ENLAAK1'], -['99', 'PROV-907'], -['99', '590367'], -['92', '20016T'], -['92', '20016'], -['101', 'KEK225'], -['101', '55075'], -['109', 'FYS2042'], -['109', '53862'], -['97', 'KK-ENMALU2'], -['100', '790Y330'], -['100', '732290'], -['94', 'FYS2004'], -['97', 'KK-ENLAAK2'], -['94', '530000'], -['66', 'KEK110'], -['66', '55395'], -['95', 'BIO-104'], -['95', '52073'], -['102', 'FYS2071'], -['102', '53051'], -['103', 'TKT21012'], -['103', '582359'], -['82', 'MAT11005'], -['82', '57118'], -['70', 'FYS1013'], -['70', '53398'], -['83', 'MAT21002'], -['83', '57119'], -['104', 'FYS2014'], -['104', '537010'], -['98', 'FYS2085'], -['98', '53399'], -['105', 'MAT21019'], -['64', 'FYS1002'], -['64', '530282'], -['81', '200203C_WT'], -['81', '200203C'], -['86', 'FYS1010'], -['86', '53704'], -['84', 'MAT21005'], -['84', '57152'], -['89', 'FYS1011'], -['89', '53705'], -['63', '99501Kaikki'], -['63', '99501Hum'], -['105', '57079'], -['71', 'FYS2010'], -['71', '53723'], -['69', 'MFK-403'], -['69', '57169'], -['106', 'FYS2074'], -['90', 'FYS2001'], -['90', '530286'], -['106', '53670'], -['72', 'FYS2011'], -['72', '53724'], -['87', 'KK-ENVALT'], -['76', '20012_WasaT'], -['76', '20012'], -['87', 'KK-ENMALU'], -['68', 'PED111'], -['75', 'FYS2012'], -['75', '53725'], -['77', 'FYS2077'], -['77', '530289'], -['68', '68152'], -['107', 'FYS2032'], -['107', '53604'], -['93', '20014T'], -['88', 'KK-RUMAME'], -['96', 'FYS2031'], -['96', '535026'], -['93', '20014'], -['79', 'ME-004'], -['79', '80144'], -['88', 'KK-RUMALU'], -['74', 'FYS2013'], -['19', '582101'], -['74', '53726'], -['78', '200250_WasaT'], -['78', '200250'], -['108', 'FYS2076'], -['67', '68153Mat'], -['67', '68153Fys'], -['67', '68153Kem'], -['110', 'MATR323'], -['110', '530006'], -['108', '53531'], -['113', 'KEK205'], -['113', '55508'], -['73', 'FYS2083'], -['73', '530177'], -['111', 'FYS2045'], -['111', '53915'], -['112', 'FYS2003'], -['112', '53703'], -['114', 'MAT21018'], -['114', '57056'], -['115', 'CSM14204'], -['115', '58144'], -['116', 'KEK222'], -['116', '55079'], -['117', 'TKT21004'], -['117', '581365'], -['118', 'FYS2081'], -['118', '53757'], -['119', 'CSM12103'], -['119', '582487'], -['120', 'CSM12101'], -['120', '582630'], -['85', 'FYS1003'], -['85', '530283'], -['85', '530137'], -['121', 'FYS2082'], -['121', '530141'], -['122', 'MATR335'], -['122', '53017'], -['123', 'FYS2078'], -['123', '53329'], -['124', 'FYS1006'], -['124', '530291'], -['125', 'CSM13102'], -['125', '582498'], -['126', 'FYS4014'], -['126', '53985'], -['127', 'MATR331'], -['127', '530237'], -['128', 'TKT21014'], -['128', '582315'], -['129', 'FYS1005'], -['129', '530140'], -['150', 'KEK201'], -['150', '55069'], -['130', 'KEK106'], -['130', '55402'], -['130', '55084'], -['131', 'MATR324'], -['131', '530153'], -['132', 'MATR320'], -['132', '530285'], -['133', 'MATR305'], -['133', '530267'], -['151', 'KEK203'], -['37', '582640'], -['37', '582497'], -['134', 'MATR329'], -['134', '530038'], -['135', 'FYS2009'], -['135', '530145'], -['136', 'MAT12003'], -['136', '57045'], -['137', 'TKT21024'], -['137', '582350'], -['138', 'TKT21008'], -['138', '58127'], -['139', 'FYS2018'], -['139', '53716'], -['140', 'MATR315'], -['140', '53340'], -['141', 'FYS1004'], -['141', '530284'], -['151', '55068'], -['142', 'MATR309'], -['142', '55722'], -['142', '53025'], -['143', 'CSM12104'], -['143', '582691'], -['144', 'CSM14303'], -['144', '58316103'], -['145', 'TKT21007'], -['145', '582353'], -['146', 'TKT21003'], -['146', '582368'], -['147', 'CSM14201'], -['147', '581361'], -['148', 'FYS1014'], -['148', '53602'], -['149', 'MAT22003'], -['149', '57701'], -['152', 'MAT21006'], -['152', '57153'], -] diff --git a/services/backend/shared/migrations/20190523_add_mandatory_courses_label.js b/services/backend/shared/migrations/20190523_add_mandatory_courses_label.js deleted file mode 100644 index a0b84e9394..0000000000 --- a/services/backend/shared/migrations/20190523_add_mandatory_courses_label.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('mandatory_courses', 'label', { type: Sequelize.STRING }) - }, - down: async () => { - await queryInterface.removeColumn('mandatory_courses', 'label') - } -} diff --git a/services/backend/shared/migrations/20190527_kone_data.js b/services/backend/shared/migrations/20190527_kone_data.js deleted file mode 100644 index 384614e986..0000000000 --- a/services/backend/shared/migrations/20190527_kone_data.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeConstraint('course_groups', 'course_groups_programmeid_fkey', { transaction }), - await queryInterface.removeConstraint('teacher_course_group', 'teacher_course_group_teacher_id_fkey', { transaction }), - await queryInterface.removeConstraint('teacher_course_group', 'teacher_course_group_course_group_id_fkey', { transaction }), - await queryInterface.removeConstraint('mandatory_courses', 'mandatory_courses_course_code_fkey', { transaction }), - await queryInterface.removeConstraint('tag_student', 'tag_student_taggedstudents_studentnumber_fkey', { transaction }), - await queryInterface.removeConstraint('tag_student', 'tag_student_tags_tagname_fkey', { transaction }), - await queryInterface.removeConstraint('unit_tag', 'unit_tag_unit_id_fkey', { transaction }), - - await queryInterface.createSchema('kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE course_groups SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE teacher_course_group SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE mandatory_courses SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE filters SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE usage_statistics SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE tag SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE tag_student SET SCHEMA kone_data', { transaction }), - await queryInterface.sequelize.query('ALTER TABLE unit_tag SET SCHEMA kone_data', { transaction }) - }) - }, - - down: async () => { - } -} diff --git a/services/backend/shared/migrations/20190701_01_add_home_country_to_student.js b/services/backend/shared/migrations/20190701_01_add_home_country_to_student.js deleted file mode 100644 index c70b55f7fb..0000000000 --- a/services/backend/shared/migrations/20190701_01_add_home_country_to_student.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('student', 'home_country_en', { type: Sequelize.STRING }) - await queryInterface.addColumn('student', 'home_country_fi', { type: Sequelize.STRING }) - await queryInterface.addColumn('student', 'home_country_sv', { type: Sequelize.STRING }) - }, - down: async () => { - await queryInterface.removeColumn('student', 'home_country_en') - await queryInterface.removeColumn('student', 'home_country_fi') - await queryInterface.removeColumn('student', 'home_country_sv') - } -} diff --git a/services/backend/shared/migrations/20190701_02_remove_unused_old_country_from_student.js b/services/backend/shared/migrations/20190701_02_remove_unused_old_country_from_student.js deleted file mode 100644 index 50e47743ba..0000000000 --- a/services/backend/shared/migrations/20190701_02_remove_unused_old_country_from_student.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.removeColumn('student', 'country') - }, - down: async () => { - await queryInterface.addColumn('student', 'country', { type: Sequelize.STRING }) - - } -} diff --git a/services/backend/shared/migrations/20190702_01_drop_old_tables.js b/services/backend/shared/migrations/20190702_01_drop_old_tables.js deleted file mode 100644 index 1bb110d657..0000000000 --- a/services/backend/shared/migrations/20190702_01_drop_old_tables.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.dropTable('course_duplicates', { transaction }) - await queryInterface.dropTable('thesis_courses', { transaction }) - }) - }, - down: async () => { - } -} diff --git a/services/backend/shared/migrations/20190705_00_transfers_delete_on_studyright_delete.js b/services/backend/shared/migrations/20190705_00_transfers_delete_on_studyright_delete.js deleted file mode 100644 index 6dc8acc30d..0000000000 --- a/services/backend/shared/migrations/20190705_00_transfers_delete_on_studyright_delete.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query('ALTER TABLE transfers DROP CONSTRAINT "transfers_studyrightid_fkey"', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers DROP CONSTRAINT "transfers_sourcecode_fkey"', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers DROP CONSTRAINT "transfers_studentnumber_fkey"', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers DROP CONSTRAINT "transfers_targetcode_fkey"', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers ADD CONSTRAINT "transfers_studyrightid_fkey" FOREIGN KEY (studyrightid) REFERENCES studyright(studyrightid) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers ADD CONSTRAINT "transfers_sourcecode_fkey" FOREIGN KEY (sourcecode) REFERENCES element_details(code) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers ADD CONSTRAINT "transfers_studentnumber_fkey" FOREIGN KEY (studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE', { transaction }) - await queryInterface.sequelize.query('ALTER TABLE transfers ADD CONSTRAINT "transfers_targetcode_fkey" FOREIGN KEY (targetcode) REFERENCES element_details(code) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE', { transaction }) - await queryInterface.sequelize.query('DELETE FROM transfers WHERE studyrightid IS NULL OR sourcecode IS NULL OR studentnumber IS NULL OR targetcode IS NULL', { transaction }) - }) - }, - down: async () => { - } -} diff --git a/services/backend/shared/migrations/20190702_02_drop_schema_kone.js b/services/backend/shared/migrations/20190710_00_delete_me_after_release.js similarity index 54% rename from services/backend/shared/migrations/20190702_02_drop_schema_kone.js rename to services/backend/shared/migrations/20190710_00_delete_me_after_release.js index d8354cd0fc..154b54b536 100644 --- a/services/backend/shared/migrations/20190702_02_drop_schema_kone.js +++ b/services/backend/shared/migrations/20190710_00_delete_me_after_release.js @@ -1,7 +1,10 @@ module.exports = { up: async (queryInterface, Sequelize) => { return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.dropSchema('kone_data', { transaction }) + await queryInterface.sequelize.query(` +INSERT INTO "migrations" ("name") VALUES +('20190710_01_trunkate_migrations.js'); +`, { transaction }) }) }, down: async () => { diff --git a/services/backend/shared/migrations/20190710_01_trunkate_migrations.js b/services/backend/shared/migrations/20190710_01_trunkate_migrations.js new file mode 100644 index 0000000000..d9bb438c69 --- /dev/null +++ b/services/backend/shared/migrations/20190710_01_trunkate_migrations.js @@ -0,0 +1,1237 @@ +module.exports = { + up: async (queryInterface, Sequelize) => { + // If you need old migrations, you can find them from 86b1aa1a3930a94f527bb5fe63ba0c76e5ca4d75 + return queryInterface.sequelize.transaction(async transaction => { + await queryInterface.sequelize.query(` +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.6.3 +-- Dumped by pg_dump version 9.6.3 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SET check_function_bodies = false; +SET client_min_messages = warning; +SET row_security = off; + +SET search_path = public, pg_catalog; + +-- +-- Name: enum_thesis_courses_thesisType; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE "enum_thesis_courses_thesisType" AS ENUM ( + 'BACHELOR', + 'MASTER' +); + + +ALTER TYPE "enum_thesis_courses_thesisType" OWNER TO postgres; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- Name: Sessions; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE "Sessions" ( + sid character varying(32) NOT NULL, + expires timestamp with time zone, + data text, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE "Sessions" OWNER TO postgres; + +-- +-- Name: course; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE course ( + code character varying(255) NOT NULL, + name jsonb, + latest_instance_date timestamp with time zone, + is_study_module boolean, + startdate timestamp with time zone, + enddate timestamp with time zone, + max_attainment_date timestamp with time zone, + min_attainment_date timestamp with time zone, + coursetypecode integer +); + + +ALTER TABLE course OWNER TO postgres; + +-- +-- Name: course_disciplines; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE course_disciplines ( + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + discipline_id character varying(255) NOT NULL, + course_id character varying(255) NOT NULL +); + + +ALTER TABLE course_disciplines OWNER TO postgres; + +-- +-- Name: course_enrollments; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE course_enrollments ( + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + courserealisation_id character varying(255) NOT NULL, + studentnumber character varying(255) NOT NULL +); + + +ALTER TABLE course_enrollments OWNER TO postgres; + +-- +-- Name: course_providers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE course_providers ( + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + coursecode character varying(255) NOT NULL, + providercode character varying(255) NOT NULL +); + + +ALTER TABLE course_providers OWNER TO postgres; + +-- +-- Name: course_types; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE course_types ( + coursetypecode integer NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE course_types OWNER TO postgres; + +-- +-- Name: courserealisation_types; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE courserealisation_types ( + realisationtypecode character varying(255) NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE courserealisation_types OWNER TO postgres; + +-- +-- Name: courserealisations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE courserealisations ( + courserealisation_id character varying(255) NOT NULL, + name jsonb, + startdate timestamp with time zone, + enddate timestamp with time zone, + parent character varying(255), + root character varying(255), + coursecode character varying(255), + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + realisationtypecode character varying(255) +); + + +ALTER TABLE courserealisations OWNER TO postgres; + +-- +-- Name: credit; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE credit ( + id character varying(255) NOT NULL, + grade character varying(255), + student_studentnumber character varying(255), + credits double precision, + ordering character varying(255), + attainment_date timestamp with time zone, + "isStudyModule" boolean, + createddate timestamp with time zone NOT NULL, + lastmodifieddate timestamp with time zone NOT NULL, + course_code character varying(255), + credittypecode integer, + semestercode integer NOT NULL +); + + +ALTER TABLE credit OWNER TO postgres; + +-- +-- Name: credit_teachers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE credit_teachers ( + credit_id character varying(255) NOT NULL, + teacher_id character varying(255) NOT NULL, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE credit_teachers OWNER TO postgres; + +-- +-- Name: credit_types; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE credit_types ( + credittypecode integer NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE credit_types OWNER TO postgres; + +-- +-- Name: disciplines; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE disciplines ( + discipline_id character varying(255) NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE disciplines OWNER TO postgres; + +-- +-- Name: element_details; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE element_details ( + code character varying(255) NOT NULL, + name jsonb, + type integer, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE element_details OWNER TO postgres; + +-- +-- Name: error_data; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE error_data ( + id character varying(255) NOT NULL, + data jsonb, + "createdAt" timestamp with time zone, + "updatedAt" timestamp with time zone +); + + +ALTER TABLE error_data OWNER TO postgres; + +-- +-- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE hibernate_sequence + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE hibernate_sequence OWNER TO postgres; + +-- +-- Name: ldapuser; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE ldapuser ( + id bigint NOT NULL, + createddate timestamp without time zone, + lastmodifieddate timestamp without time zone, + username character varying(255) NOT NULL +); + + +ALTER TABLE ldapuser OWNER TO postgres; + +-- +-- Name: migrations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE migrations ( + name character varying(255) NOT NULL +); + + +ALTER TABLE migrations OWNER TO postgres; + +-- +-- Name: organization; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE organization ( + code character varying(255) NOT NULL, + name jsonb +); + + +ALTER TABLE organization OWNER TO postgres; + +-- +-- Name: providers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE providers ( + providercode character varying(255) NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE providers OWNER TO postgres; + +-- +-- Name: semester_enrollments; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE semester_enrollments ( + id bigint NOT NULL, + enrollmenttype integer, + enrollment_date timestamp with time zone, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + studentnumber character varying(255), + semestercode integer +); + + +ALTER TABLE semester_enrollments OWNER TO postgres; + +-- +-- Name: semester_enrollments_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE semester_enrollments_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE semester_enrollments_id_seq OWNER TO postgres; + +-- +-- Name: semester_enrollments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE semester_enrollments_id_seq OWNED BY semester_enrollments.id; + + +-- +-- Name: semesters; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE semesters ( + semestercode integer NOT NULL, + name jsonb, + startdate timestamp with time zone, + enddate timestamp with time zone, + yearcode integer, + yearname character varying(255), + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE semesters OWNER TO postgres; + +-- +-- Name: sequence; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE sequence ( + seq_name character varying(50) NOT NULL, + seq_count numeric(38,0) +); + + +ALTER TABLE sequence OWNER TO postgres; + +-- +-- Name: student; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE student ( + studentnumber character varying(255) NOT NULL, + lastname character varying(255), + firstnames character varying(255), + abbreviatedname character varying(255), + birthdate timestamp with time zone, + communicationlanguage character varying(255), + creditcount integer, + dateofuniversityenrollment timestamp with time zone, + matriculationexamination character varying(255), + email character varying(255), + phone character varying(255), + city_fi character varying(255), + city_sv character varying(255), + national_student_number character varying(255), + zipcode character varying(255), + address character varying(255), + address2 character varying(255), + language_fi character varying(255), + language_sv character varying(255), + language_en character varying(255), + age integer, + mobile character varying(255), + home_county_id integer, + country_fi character varying(255), + country_sv character varying(255), + country_en character varying(255), + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + gender_code integer, + gender_fi character varying(255), + gender_sv character varying(255), + gender_en character varying(255), + home_country_en character varying(255), + home_country_fi character varying(255), + home_country_sv character varying(255) +); + + +ALTER TABLE student OWNER TO postgres; + +-- +-- Name: student_list; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE student_list ( + id integer NOT NULL, + key character varying(255), + max bigint, + description character varying(255), + student_numbers jsonb +); + + +ALTER TABLE student_list OWNER TO postgres; + +-- +-- Name: student_list_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE student_list_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE student_list_id_seq OWNER TO postgres; + +-- +-- Name: student_list_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE student_list_id_seq OWNED BY student_list.id; + + +-- +-- Name: studyright; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE studyright ( + studyrightid bigint NOT NULL, + canceldate timestamp with time zone, + cancelorganisation character varying(255), + enddate timestamp with time zone, + givendate timestamp with time zone, + graduated integer, + highlevelname character varying(255), + prioritycode integer, + startdate timestamp with time zone, + studystartdate timestamp with time zone, + organization_code character varying(255), + student_studentnumber character varying(255), + extentcode integer +); + + +ALTER TABLE studyright OWNER TO postgres; + +-- +-- Name: studyright_elements; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE studyright_elements ( + id integer NOT NULL, + startdate timestamp with time zone, + enddate timestamp with time zone, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + studyrightid bigint, + code character varying(255), + studentnumber character varying(255) +); + + +ALTER TABLE studyright_elements OWNER TO postgres; + +-- +-- Name: studyright_elements_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE studyright_elements_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE studyright_elements_id_seq OWNER TO postgres; + +-- +-- Name: studyright_elements_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE studyright_elements_id_seq OWNED BY studyright_elements.id; + + +-- +-- Name: studyright_extents; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE studyright_extents ( + extentcode integer NOT NULL, + name jsonb, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL +); + + +ALTER TABLE studyright_extents OWNER TO postgres; + +-- +-- Name: teacher; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE teacher ( + id character varying(255) NOT NULL, + code character varying(255), + name character varying(255) +); + + +ALTER TABLE teacher OWNER TO postgres; + +-- +-- Name: teacher_course_group_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE teacher_course_group_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE teacher_course_group_id_seq OWNER TO postgres; + +-- +-- Name: transfers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE transfers ( + id integer NOT NULL, + transferdate timestamp with time zone, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + studentnumber character varying(255), + studyrightid bigint, + sourcecode character varying(255), + targetcode character varying(255) +); + + +ALTER TABLE transfers OWNER TO postgres; + +-- +-- Name: transfers_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE transfers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE transfers_id_seq OWNER TO postgres; + +-- +-- Name: transfers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE transfers_id_seq OWNED BY transfers.id; + + +-- +-- Name: unit; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE unit ( + id bigint NOT NULL, + name character varying(255), + enabled boolean +); + + +ALTER TABLE unit OWNER TO postgres; + +-- +-- Name: unit_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE unit_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE unit_id_seq OWNER TO postgres; + +-- +-- Name: unit_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE unit_id_seq OWNED BY unit.id; + + +-- +-- Name: semester_enrollments id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY semester_enrollments ALTER COLUMN id SET DEFAULT nextval('semester_enrollments_id_seq'::regclass); + + +-- +-- Name: student_list id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY student_list ALTER COLUMN id SET DEFAULT nextval('student_list_id_seq'::regclass); + + +-- +-- Name: studyright_elements id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_elements ALTER COLUMN id SET DEFAULT nextval('studyright_elements_id_seq'::regclass); + + +-- +-- Name: transfers id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers ALTER COLUMN id SET DEFAULT nextval('transfers_id_seq'::regclass); + + +-- +-- Name: unit id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY unit ALTER COLUMN id SET DEFAULT nextval('unit_id_seq'::regclass); + + +-- +-- Name: Sessions Sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY "Sessions" + ADD CONSTRAINT "Sessions_pkey" PRIMARY KEY (sid); + + +-- +-- Name: course_disciplines course_disciplines_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_disciplines + ADD CONSTRAINT course_disciplines_pkey PRIMARY KEY (discipline_id, course_id); + + +-- +-- Name: course_enrollments course_enrollments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_enrollments + ADD CONSTRAINT course_enrollments_pkey PRIMARY KEY (courserealisation_id, studentnumber); + + +-- +-- Name: course course_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course + ADD CONSTRAINT course_pkey PRIMARY KEY (code); + + +-- +-- Name: course_providers course_providers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_providers + ADD CONSTRAINT course_providers_pkey PRIMARY KEY (coursecode, providercode); + + +-- +-- Name: course_types course_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_types + ADD CONSTRAINT course_types_pkey PRIMARY KEY (coursetypecode); + + +-- +-- Name: courserealisation_types courserealisation_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY courserealisation_types + ADD CONSTRAINT courserealisation_types_pkey PRIMARY KEY (realisationtypecode); + + +-- +-- Name: courserealisations courserealisations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY courserealisations + ADD CONSTRAINT courserealisations_pkey PRIMARY KEY (courserealisation_id); + + +-- +-- Name: credit credit_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit + ADD CONSTRAINT credit_pkey PRIMARY KEY (id); + + +-- +-- Name: credit_teachers credit_teachers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit_teachers + ADD CONSTRAINT credit_teachers_pkey PRIMARY KEY (credit_id, teacher_id); + + +-- +-- Name: credit_types credit_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit_types + ADD CONSTRAINT credit_types_pkey PRIMARY KEY (credittypecode); + + +-- +-- Name: disciplines disciplines_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY disciplines + ADD CONSTRAINT disciplines_pkey PRIMARY KEY (discipline_id); + + +-- +-- Name: element_details element_details_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY element_details + ADD CONSTRAINT element_details_pkey PRIMARY KEY (code); + + +-- +-- Name: error_data error_data_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY error_data + ADD CONSTRAINT error_data_pkey PRIMARY KEY (id); + + +-- +-- Name: ldapuser ldapuser_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY ldapuser + ADD CONSTRAINT ldapuser_pkey PRIMARY KEY (id); + + +-- +-- Name: ldapuser ldapuser_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY ldapuser + ADD CONSTRAINT ldapuser_username_key UNIQUE (username); + + +-- +-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY migrations + ADD CONSTRAINT migrations_pkey PRIMARY KEY (name); + + +-- +-- Name: organization organization_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY organization + ADD CONSTRAINT organization_pkey PRIMARY KEY (code); + + +-- +-- Name: providers providers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY providers + ADD CONSTRAINT providers_pkey PRIMARY KEY (providercode); + + +-- +-- Name: semester_enrollments semester_enrollments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY semester_enrollments + ADD CONSTRAINT semester_enrollments_pkey PRIMARY KEY (id); + + +-- +-- Name: semesters semesters_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY semesters + ADD CONSTRAINT semesters_pkey PRIMARY KEY (semestercode); + + +-- +-- Name: sequence sequence_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY sequence + ADD CONSTRAINT sequence_pkey PRIMARY KEY (seq_name); + + +-- +-- Name: student_list student_list_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY student_list + ADD CONSTRAINT student_list_pkey PRIMARY KEY (id); + + +-- +-- Name: student student_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY student + ADD CONSTRAINT student_pkey PRIMARY KEY (studentnumber); + + +-- +-- Name: studyright_elements studyright_elements_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_elements + ADD CONSTRAINT studyright_elements_pkey PRIMARY KEY (id); + + +-- +-- Name: studyright_extents studyright_extents_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_extents + ADD CONSTRAINT studyright_extents_pkey PRIMARY KEY (extentcode); + + +-- +-- Name: studyright studyright_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright + ADD CONSTRAINT studyright_pkey PRIMARY KEY (studyrightid); + + +-- +-- Name: teacher teacher_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY teacher + ADD CONSTRAINT teacher_pkey PRIMARY KEY (id); + + +-- +-- Name: transfers transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers + ADD CONSTRAINT transfers_pkey PRIMARY KEY (id); + + +-- +-- Name: unit unit_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY unit + ADD CONSTRAINT unit_name_key UNIQUE (name); + + +-- +-- Name: unit unit_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY unit + ADD CONSTRAINT unit_pkey PRIMARY KEY (id); + + +-- +-- Name: course_providers_providercode_coursecode; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX course_providers_providercode_coursecode ON course_providers USING btree (providercode, coursecode); + + +-- +-- Name: credit_attainment_date; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX credit_attainment_date ON credit USING btree (attainment_date); + + +-- +-- Name: credit_course_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX credit_course_code ON credit USING btree (course_code); + + +-- +-- Name: credit_student_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX credit_student_studentnumber ON credit USING btree (student_studentnumber); + + +-- +-- Name: credit_teachers_credit_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX credit_teachers_credit_id ON credit_teachers USING btree (credit_id); + + +-- +-- Name: credit_teachers_teacher_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX credit_teachers_teacher_id ON credit_teachers USING btree (teacher_id); + + +-- +-- Name: semester_enrollment_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX semester_enrollment_studentnumber ON semester_enrollments USING btree (studentnumber); + + +-- +-- Name: semester_enrollments_semestercode_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX semester_enrollments_semestercode_studentnumber ON semester_enrollments USING btree (semestercode, studentnumber); + + +-- +-- Name: semester_enrollments_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX semester_enrollments_studentnumber ON semester_enrollments USING btree (studentnumber); + + +-- +-- Name: studyright_elements_startdate; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX studyright_elements_startdate ON studyright_elements USING btree (startdate); + + +-- +-- Name: studyright_elements_startdate_enddate_studyrightid_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX studyright_elements_startdate_enddate_studyrightid_code ON studyright_elements USING btree (startdate, enddate, studyrightid, code); + + +-- +-- Name: studyright_student_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX studyright_student_studentnumber ON studyright USING btree (student_studentnumber); + + +-- +-- Name: transfers_studentnumber; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX transfers_studentnumber ON transfers USING btree (studentnumber); + + +-- +-- Name: course course_coursetypecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course + ADD CONSTRAINT course_coursetypecode_fkey FOREIGN KEY (coursetypecode) REFERENCES course_types(coursetypecode) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: course_disciplines course_disciplines_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_disciplines + ADD CONSTRAINT course_disciplines_course_id_fkey FOREIGN KEY (course_id) REFERENCES course(code) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: course_disciplines course_disciplines_discipline_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_disciplines + ADD CONSTRAINT course_disciplines_discipline_id_fkey FOREIGN KEY (discipline_id) REFERENCES disciplines(discipline_id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: course_enrollments course_enrollments_courserealisation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_enrollments + ADD CONSTRAINT course_enrollments_courserealisation_id_fkey FOREIGN KEY (courserealisation_id) REFERENCES courserealisations(courserealisation_id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: course_enrollments course_enrollments_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_enrollments + ADD CONSTRAINT course_enrollments_studentnumber_fkey FOREIGN KEY (studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: course_providers course_providers_coursecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_providers + ADD CONSTRAINT course_providers_coursecode_fkey FOREIGN KEY (coursecode) REFERENCES course(code) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: course_providers course_providers_providercode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY course_providers + ADD CONSTRAINT course_providers_providercode_fkey FOREIGN KEY (providercode) REFERENCES providers(providercode) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: courserealisations courserealisations_coursecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY courserealisations + ADD CONSTRAINT courserealisations_coursecode_fkey FOREIGN KEY (coursecode) REFERENCES course(code) ON UPDATE CASCADE; + + +-- +-- Name: courserealisations courserealisations_realisationtypecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY courserealisations + ADD CONSTRAINT courserealisations_realisationtypecode_fkey FOREIGN KEY (realisationtypecode) REFERENCES courserealisation_types(realisationtypecode) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: credit credit_course_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit + ADD CONSTRAINT credit_course_code_fkey FOREIGN KEY (course_code) REFERENCES course(code) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: credit credit_credittypecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit + ADD CONSTRAINT credit_credittypecode_fkey FOREIGN KEY (credittypecode) REFERENCES credit_types(credittypecode) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: credit credit_semestercode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit + ADD CONSTRAINT credit_semestercode_fkey FOREIGN KEY (semestercode) REFERENCES semesters(semestercode) ON UPDATE CASCADE; + + +-- +-- Name: credit credit_student_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit + ADD CONSTRAINT credit_student_studentnumber_fkey FOREIGN KEY (student_studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE; + + +-- +-- Name: credit_teachers credit_teachers_credit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit_teachers + ADD CONSTRAINT credit_teachers_credit_id_fkey FOREIGN KEY (credit_id) REFERENCES credit(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: credit_teachers credit_teachers_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY credit_teachers + ADD CONSTRAINT credit_teachers_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES teacher(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: semester_enrollments semester_enrollments_semestercode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY semester_enrollments + ADD CONSTRAINT semester_enrollments_semestercode_fkey FOREIGN KEY (semestercode) REFERENCES semesters(semestercode) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: semester_enrollments semester_enrollments_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY semester_enrollments + ADD CONSTRAINT semester_enrollments_studentnumber_fkey FOREIGN KEY (studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: studyright_elements studyright_elements_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_elements + ADD CONSTRAINT studyright_elements_code_fkey FOREIGN KEY (code) REFERENCES element_details(code) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: studyright_elements studyright_elements_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_elements + ADD CONSTRAINT studyright_elements_studentnumber_fkey FOREIGN KEY (studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: studyright_elements studyright_elements_studyrightid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright_elements + ADD CONSTRAINT studyright_elements_studyrightid_fkey FOREIGN KEY (studyrightid) REFERENCES studyright(studyrightid) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: studyright studyright_extentcode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright + ADD CONSTRAINT studyright_extentcode_fkey FOREIGN KEY (extentcode) REFERENCES studyright_extents(extentcode) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: studyright studyright_student_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY studyright + ADD CONSTRAINT studyright_student_studentnumber_fkey FOREIGN KEY (student_studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE; + + +-- +-- Name: transfers transfers_sourcecode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers + ADD CONSTRAINT transfers_sourcecode_fkey FOREIGN KEY (sourcecode) REFERENCES element_details(code) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: transfers transfers_studentnumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers + ADD CONSTRAINT transfers_studentnumber_fkey FOREIGN KEY (studentnumber) REFERENCES student(studentnumber) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: transfers transfers_studyrightid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers + ADD CONSTRAINT transfers_studyrightid_fkey FOREIGN KEY (studyrightid) REFERENCES studyright(studyrightid) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: transfers transfers_targetcode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY transfers + ADD CONSTRAINT transfers_targetcode_fkey FOREIGN KEY (targetcode) REFERENCES element_details(code) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- +`, { transaction }) + }) + }, + down: async () => { + } +} From fd3d7f51c0bf3bc1da1f2328b8e89a440034f875 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Wed, 10 Jul 2019 16:01:55 +0300 Subject: [PATCH 6/6] Drop unused old table ldapuser --- .../shared/migrations/20190710_03_drop_ldapuser.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 services/backend/shared/migrations/20190710_03_drop_ldapuser.js diff --git a/services/backend/shared/migrations/20190710_03_drop_ldapuser.js b/services/backend/shared/migrations/20190710_03_drop_ldapuser.js new file mode 100644 index 0000000000..4b3f37451e --- /dev/null +++ b/services/backend/shared/migrations/20190710_03_drop_ldapuser.js @@ -0,0 +1,9 @@ +module.exports = { + up: async (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction(async transaction => { + await queryInterface.dropTable('ldapuser', { transaction }) + }) + }, + down: async () => { + } +}