lms-sync 1.0.17 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apiConnections/mapping.js +88 -70
- package/models/index.js +1 -1
- package/package.json +1 -1
- package/recordError.log +0 -4810
- package/recordSuccess.log +0 -14092
@@ -32,6 +32,19 @@ const server = {
|
|
32
32
|
console.log("########################################################")
|
33
33
|
console.log("");
|
34
34
|
|
35
|
+
const db_schema = schema
|
36
|
+
let maxIds = await Campuses.max('_id'); //Fetch maximum _id directly from the campuses model
|
37
|
+
let maxIdsSem = await Semesters.max('_id'); //Fetch maximum _id directly from the campuses model
|
38
|
+
|
39
|
+
let maxId = maxIds|| 0;
|
40
|
+
let maxIdSems = maxIdsSem|| 0;
|
41
|
+
|
42
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Campuses__id_seq"`);
|
43
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Campuses__id_seq" RESTART WITH ${maxId + 1}`);
|
44
|
+
|
45
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Semesters__id_seq"`);
|
46
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Semesters__id_seq" RESTART WITH ${maxIdSems + 1}`);
|
47
|
+
|
35
48
|
let userDefPayload = {
|
36
49
|
email: 'ccci_integrator@gmail.com',
|
37
50
|
password: '$2a$12$Q.h3Q9IN6vsIxGBa/EgfOOABeXTcwxt4t9cu4nqAK.nczGRRtZJUS',
|
@@ -47,6 +60,8 @@ const server = {
|
|
47
60
|
|
48
61
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
49
62
|
|
63
|
+
|
64
|
+
|
50
65
|
let semesterData = [
|
51
66
|
{
|
52
67
|
code: '1st Semester',
|
@@ -110,10 +125,7 @@ const server = {
|
|
110
125
|
let errorCounter = 0
|
111
126
|
let uniqueErrors = new Set()
|
112
127
|
|
113
|
-
|
114
|
-
let maxIds = await Campuses.max('_id'); //Fetch maximum _id directly from the campuses model
|
115
|
-
let maxId = maxIds|| 0;
|
116
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Campuses__id_seq" RESTART WITH ${maxId + 1}`);
|
128
|
+
|
117
129
|
|
118
130
|
let uCode = new Set()
|
119
131
|
let uName = new Set()
|
@@ -217,6 +229,12 @@ const server = {
|
|
217
229
|
console.log("########################################################")
|
218
230
|
console.log("");
|
219
231
|
|
232
|
+
const db_schema = schema
|
233
|
+
let maxIds = await Colleges.max('_id'); // Fetch maximum _id directly from the Colleges model
|
234
|
+
let maxId = maxIds|| 0;
|
235
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Colleges__id_seq"`);
|
236
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Colleges__id_seq" RESTART WITH ${maxId + 1}`);
|
237
|
+
|
220
238
|
const collegeApi = await api.College()
|
221
239
|
const campusApi = await api.Campus()
|
222
240
|
|
@@ -241,11 +259,6 @@ const server = {
|
|
241
259
|
let errorCounter = 0
|
242
260
|
let uniqueErrors = new Set()
|
243
261
|
|
244
|
-
const db_schema = schema
|
245
|
-
let maxIds = await Colleges.max('_id'); // Fetch maximum _id directly from the Colleges model
|
246
|
-
let maxId = maxIds|| 0;
|
247
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Colleges__id_seq" RESTART WITH ${maxId + 1}`);
|
248
|
-
|
249
262
|
// let migratedAt = new Date() //present date of the migration
|
250
263
|
// let migratedTable = 'colleges' // sql counterpart main table
|
251
264
|
// let referenceId = collegeApi.id // id of the data
|
@@ -353,6 +366,12 @@ const server = {
|
|
353
366
|
console.log("########################################################")
|
354
367
|
console.log("");
|
355
368
|
|
369
|
+
const db_schema = schema
|
370
|
+
let maxIds = await AcademicDepartments.max('_id'); // Fetch maximum _id directly from the AcademicDepartments model
|
371
|
+
let maxId = maxIds|| 0;
|
372
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."AcademicDepartments__id_seq"`);
|
373
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicDepartments__id_seq" RESTART WITH ${maxId + 1}`);
|
374
|
+
|
356
375
|
const departmentApi = await api.Department()
|
357
376
|
const campusApi = await api.Campus()
|
358
377
|
const collegeApi = await api.College()
|
@@ -384,11 +403,6 @@ const server = {
|
|
384
403
|
let errorCounter = 0
|
385
404
|
let uniqueErrors = new Set()
|
386
405
|
|
387
|
-
const db_schema = schema
|
388
|
-
let maxIds = await AcademicDepartments.max('_id'); // Fetch maximum _id directly from the AcademicDepartments model
|
389
|
-
let maxId = maxIds|| 0;
|
390
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicDepartments__id_seq" RESTART WITH ${maxId + 1}`);
|
391
|
-
|
392
406
|
let uCode = new Set()
|
393
407
|
let uName = new Set()
|
394
408
|
let newAcadDept = []
|
@@ -555,6 +569,12 @@ const server = {
|
|
555
569
|
console.log("########################################################")
|
556
570
|
console.log("");
|
557
571
|
|
572
|
+
const db_schema = schema
|
573
|
+
let maxIds = await Instructors.max('_id'); //Fetch maximum _id directly from the Instructors model
|
574
|
+
let maxId = maxIds|| 0;
|
575
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Instructors__id_seq"`);
|
576
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Instructors__id_seq" RESTART WITH ${maxId + 1}`);
|
577
|
+
|
558
578
|
const instructorApi = await api.Instructor()
|
559
579
|
const departmentApi = await api.Department()
|
560
580
|
|
@@ -585,12 +605,6 @@ const server = {
|
|
585
605
|
let errorCounter = 0
|
586
606
|
let uniqueErrors = new Set()
|
587
607
|
|
588
|
-
|
589
|
-
const db_schema = schema
|
590
|
-
let maxIds = await Instructors.max('_id'); //Fetch maximum _id directly from the Instructors model
|
591
|
-
let maxId = maxIds|| 0;
|
592
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Instructors__id_seq" RESTART WITH ${maxId + 1}`);
|
593
|
-
|
594
608
|
let uDept = new Set()
|
595
609
|
let uCamp = new Set()
|
596
610
|
let uLname = new Set()
|
@@ -728,6 +742,12 @@ const server = {
|
|
728
742
|
console.log("########################################################")
|
729
743
|
console.log("");
|
730
744
|
|
745
|
+
const db_schema = schema
|
746
|
+
let maxIds = await Courses.max('_id'); //Fetch maximum _id directly from the Courses model
|
747
|
+
let maxId = maxIds|| 0;
|
748
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Courses__id_seq"`);
|
749
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Courses__id_seq" RESTART WITH ${maxId + 1}`);
|
750
|
+
|
731
751
|
const studentApi = (await api.Student()).data
|
732
752
|
|
733
753
|
const courseApi = await api.Course()
|
@@ -761,12 +781,6 @@ const server = {
|
|
761
781
|
let errorCounter = 0
|
762
782
|
let uniqueErrors = new Set()
|
763
783
|
|
764
|
-
const db_schema = schema
|
765
|
-
let maxIds = await Courses.max('_id'); //Fetch maximum _id directly from the Courses model
|
766
|
-
let maxId = maxIds|| 0;
|
767
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Courses__id_seq" RESTART WITH ${maxId + 1}`);
|
768
|
-
|
769
|
-
|
770
784
|
let uCode = new Set()
|
771
785
|
let uName = new Set()
|
772
786
|
let uMajor = new Set()
|
@@ -885,6 +899,12 @@ const server = {
|
|
885
899
|
console.log("########################################################")
|
886
900
|
console.log("");
|
887
901
|
|
902
|
+
const db_schema = schema
|
903
|
+
let maxIds = await Rooms.max('_id'); // Fetch maximum _id directly from the Rooms model
|
904
|
+
let maxId = maxIds|| 0;
|
905
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Rooms__id_seq"`);
|
906
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Rooms__id_seq" RESTART WITH ${maxId + 1}`);
|
907
|
+
|
888
908
|
const subjectRoom = await api.Subject()
|
889
909
|
const roomApi = await api.Room()
|
890
910
|
|
@@ -912,12 +932,6 @@ const server = {
|
|
912
932
|
let errorCounter = 0
|
913
933
|
let uniqueErrors = new Set()
|
914
934
|
|
915
|
-
|
916
|
-
const db_schema = schema
|
917
|
-
let maxIds = await Rooms.max('_id'); // Fetch maximum _id directly from the Rooms model
|
918
|
-
let maxId = maxIds|| 0;
|
919
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Rooms__id_seq" RESTART WITH ${maxId + 1}`);
|
920
|
-
|
921
935
|
let uName = new Set()
|
922
936
|
let uCampus = new Set()
|
923
937
|
|
@@ -1024,6 +1038,12 @@ const server = {
|
|
1024
1038
|
console.log("########################################################")
|
1025
1039
|
console.log("");
|
1026
1040
|
|
1041
|
+
const db_schema = schema
|
1042
|
+
let maxIds = await AcademicYears.max('_id'); // Fetch maximum _id directly from the AcademicYears model
|
1043
|
+
let maxId = maxIds|| 0;
|
1044
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."AcademicYears__id_seq"`);
|
1045
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicYears__id_seq" RESTART WITH ${maxId + 1}`);
|
1046
|
+
|
1027
1047
|
const acadYearApi = await api.AcademicYear()
|
1028
1048
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
1029
1049
|
|
@@ -1033,10 +1053,6 @@ const server = {
|
|
1033
1053
|
|
1034
1054
|
const { acadYearResult, currentSchoolYear } = acadYearApi;
|
1035
1055
|
|
1036
|
-
const db_schema = schema
|
1037
|
-
let maxIds = await AcademicYears.max('_id'); // Fetch maximum _id directly from the AcademicYears model
|
1038
|
-
let maxId = maxIds|| 0;
|
1039
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."AcademicYears__id_seq" RESTART WITH ${maxId + 1}`);
|
1040
1056
|
|
1041
1057
|
let uFrom = new Set()
|
1042
1058
|
let uTo = new Set()
|
@@ -1145,6 +1161,12 @@ const server = {
|
|
1145
1161
|
console.log("########################################################")
|
1146
1162
|
console.log("");
|
1147
1163
|
|
1164
|
+
const db_schema = schema
|
1165
|
+
let maxIds = await Subjects.max('_id'); // Fetch maximum _id directly from the Subjects model
|
1166
|
+
let maxId = maxIds|| 0;
|
1167
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Subjects__id_seq"`);
|
1168
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Subjects__id_seq" RESTART WITH ${maxId + 1}`);
|
1169
|
+
|
1148
1170
|
const studentSubject = (await api.Student()).data
|
1149
1171
|
|
1150
1172
|
const subjectApi = await api.Subject()
|
@@ -1173,11 +1195,6 @@ const server = {
|
|
1173
1195
|
let errorCounter = 0
|
1174
1196
|
let uniqueErrors = new Set()
|
1175
1197
|
|
1176
|
-
const db_schema = schema
|
1177
|
-
let maxIds = await Subjects.max('_id'); // Fetch maximum _id directly from the Subjects model
|
1178
|
-
let maxId = maxIds|| 0;
|
1179
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Subjects__id_seq" RESTART WITH ${maxId + 1}`);
|
1180
|
-
|
1181
1198
|
let uCode = new Set()
|
1182
1199
|
let uName = new Set()
|
1183
1200
|
let uUnits = new Set()
|
@@ -1308,6 +1325,12 @@ const server = {
|
|
1308
1325
|
console.log(" Schedules Migration ")
|
1309
1326
|
console.log("########################################################")
|
1310
1327
|
console.log("");
|
1328
|
+
|
1329
|
+
const db_schema = schema
|
1330
|
+
let maxIds = await Schedules.max('_id'); // Fetch maximum _id directly from the Schedules model
|
1331
|
+
let maxId = maxIds|| 0;
|
1332
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Schedules__id_seq"`);
|
1333
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Schedules__id_seq" RESTART WITH ${maxId + 1}`);
|
1311
1334
|
|
1312
1335
|
const scheduleApi = await api.Schedule()
|
1313
1336
|
const userMail = await Users.findOne({ where: { email: 'ccci_integrator@gmail.com' } });
|
@@ -1315,13 +1338,6 @@ const server = {
|
|
1315
1338
|
let createdCounter = 0
|
1316
1339
|
let errorCounter = 0
|
1317
1340
|
let uniqueErrors = new Set()
|
1318
|
-
|
1319
|
-
|
1320
|
-
const db_schema = schema
|
1321
|
-
let maxIds = await Schedules.max('_id'); // Fetch maximum _id directly from the Schedules model
|
1322
|
-
let maxId = maxIds|| 0;
|
1323
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Schedules__id_seq" RESTART WITH ${maxId + 1}`);
|
1324
|
-
|
1325
1341
|
|
1326
1342
|
let uName = new Set()
|
1327
1343
|
let uFrom = new Set()
|
@@ -1462,6 +1478,12 @@ const server = {
|
|
1462
1478
|
console.log("########################################################")
|
1463
1479
|
console.log("");
|
1464
1480
|
|
1481
|
+
const db_schema = schema
|
1482
|
+
let maxIds = await Students.max('_id'); // Fetch maximum _id directly from the Students model
|
1483
|
+
let maxId = maxIds|| 0;
|
1484
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Students__id_seq"`);
|
1485
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Students__id_seq" RESTART WITH ${maxId + 1}`);
|
1486
|
+
|
1465
1487
|
const studentApi = await api.Student()
|
1466
1488
|
|
1467
1489
|
const campusSeq = await Campuses.findAll()
|
@@ -1481,12 +1503,6 @@ const server = {
|
|
1481
1503
|
|
1482
1504
|
const emailDomain = 'default.msc.edu.ph';
|
1483
1505
|
|
1484
|
-
const db_schema = schema
|
1485
|
-
let maxIds = await Students.max('_id'); // Fetch maximum _id directly from the Students model
|
1486
|
-
let maxId = maxIds|| 0;
|
1487
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Students__id_seq" RESTART WITH ${maxId + 1}`);
|
1488
|
-
|
1489
|
-
|
1490
1506
|
let uNum = new Set()
|
1491
1507
|
let uLname = new Set()
|
1492
1508
|
let uMname = new Set()
|
@@ -1618,6 +1634,12 @@ const server = {
|
|
1618
1634
|
console.log(" Sections Migration ");
|
1619
1635
|
console.log("########################################################");
|
1620
1636
|
console.log("");
|
1637
|
+
|
1638
|
+
const db_schema = schema
|
1639
|
+
let maxIds = await Sections.max('_id'); // Fetch maximum _id directly from the Sections model
|
1640
|
+
let maxId = maxIds|| 0;
|
1641
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."Sections__id_seq"`);
|
1642
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Sections__id_seq" RESTART WITH ${maxId + 1}`);
|
1621
1643
|
|
1622
1644
|
const student = (await api.Student()).data;
|
1623
1645
|
|
@@ -1638,12 +1660,6 @@ const server = {
|
|
1638
1660
|
let errorCounter = 0
|
1639
1661
|
let uniqueErrors = new Set()
|
1640
1662
|
|
1641
|
-
|
1642
|
-
const db_schema = schema
|
1643
|
-
let maxIds = await Sections.max('_id'); // Fetch maximum _id directly from the Sections model
|
1644
|
-
let maxId = maxIds|| 0;
|
1645
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."Sections__id_seq" RESTART WITH ${maxId + 1}`);
|
1646
|
-
|
1647
1663
|
let uName = new Set()
|
1648
1664
|
let uCode = new Set()
|
1649
1665
|
let uSub = new Set()
|
@@ -1823,6 +1839,12 @@ const server = {
|
|
1823
1839
|
console.log("########################################################")
|
1824
1840
|
console.log("");
|
1825
1841
|
|
1842
|
+
const db_schema = schema
|
1843
|
+
let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
1844
|
+
let maxId = maxIds|| 0;
|
1845
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."EnrolledStudents__id_seq"`);
|
1846
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
1847
|
+
|
1826
1848
|
const studentApi = (await api.Student()).data
|
1827
1849
|
const instructorApi = await api.Instructor()
|
1828
1850
|
|
@@ -1841,11 +1863,6 @@ const server = {
|
|
1841
1863
|
let errorCounter = 0
|
1842
1864
|
let uniqueErrors = new Set()
|
1843
1865
|
|
1844
|
-
const db_schema = schema
|
1845
|
-
let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
1846
|
-
let maxId = maxIds|| 0;
|
1847
|
-
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
1848
|
-
|
1849
1866
|
let uStud = new Set()
|
1850
1867
|
let uCrs = new Set()
|
1851
1868
|
let uIns = new Set()
|
@@ -2051,6 +2068,12 @@ const server = {
|
|
2051
2068
|
console.log("########################################################")
|
2052
2069
|
console.log("");
|
2053
2070
|
|
2071
|
+
const db_schema = schema
|
2072
|
+
let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
2073
|
+
let maxId = maxIds|| 0;
|
2074
|
+
await db.sequelize.query(`CREATE SEQUENCE IF NOT EXISTS ${db_schema}."EnrolledStudents__id_seq"`);
|
2075
|
+
await db.sequelize.query(`ALTER SEQUENCE ${db_schema}."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
2076
|
+
|
2054
2077
|
const studentApi = (await api.Student()).data
|
2055
2078
|
const instructorApi = await api.Instructor()
|
2056
2079
|
|
@@ -2069,11 +2092,6 @@ const server = {
|
|
2069
2092
|
let uniqueErrors = new Set()
|
2070
2093
|
|
2071
2094
|
|
2072
|
-
let maxIds = await EnrolledStudents.max('_id'); // Fetch maximum _id directly from the EnrolledStudents model
|
2073
|
-
let maxId = maxIds|| 0;
|
2074
|
-
await db.sequelize.query(`ALTER SEQUENCE public_migrations."EnrolledStudents__id_seq" RESTART WITH ${maxId + 1}`);
|
2075
|
-
|
2076
|
-
|
2077
2095
|
for (let i = 0; i < studentApi.length; i++){
|
2078
2096
|
try {
|
2079
2097
|
|
package/models/index.js
CHANGED
@@ -12,7 +12,7 @@ const config = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'target.json'
|
|
12
12
|
|
13
13
|
const schema = config.schema || "default_schema"
|
14
14
|
|
15
|
-
let sequelize = new Sequelize(config.database, config.username, config.password, config)
|
15
|
+
let sequelize = new Sequelize(config.database, config.username, config.password, config.port, config)
|
16
16
|
|
17
17
|
fs
|
18
18
|
.readdirSync(__dirname)
|