Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 7f8f539

Browse files
committed
chore: impronvments for model school
1 parent 1e4ba79 commit 7f8f539

File tree

5 files changed

+275
-18
lines changed

5 files changed

+275
-18
lines changed

Docker/custom-postgresql.conf

+4
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ shared_preload_libraries=timescaledb
7070
shared_preload_libraries=timescaledb
7171
shared_preload_libraries=timescaledb
7272
shared_preload_libraries=timescaledb
73+
shared_preload_libraries=timescaledb
74+
shared_preload_libraries=timescaledb
75+
shared_preload_libraries=timescaledb
76+
shared_preload_libraries=timescaledb

Docker/docker-compose.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: '3.8'
22

33
services:
4-
timescaledb:
4+
eduprime_db:
55
image: timescale/timescaledb:latest-pg16
6-
container_name: eduprime-db
6+
container_name: eduprime_db
77
environment:
88
POSTGRES_DB: ${POSTGRES_DB}
99
POSTGRES_USER: ${POSTGRES_USER}
@@ -14,7 +14,7 @@ services:
1414
ports:
1515
- '5432:5432'
1616
volumes:
17-
- timescaledb_data:/var/lib/postgresql/data
17+
- eduprime_db_data:/var/lib/postgresql/data
1818
- ./custom-postgresql.conf:/etc/postgresql/postgresql.conf
1919
entrypoint: >
2020
sh -c "apk add --no-cache tzdata &&
@@ -23,4 +23,4 @@ services:
2323
echo 'shared_preload_libraries=timescaledb' >> /etc/postgresql/postgresql.conf &&
2424
exec docker-entrypoint.sh postgres"
2525
volumes:
26-
timescaledb_data:
26+
eduprime_db_data:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- AlterTable
2+
ALTER TABLE "School" ADD COLUMN "abbreviation" TEXT,
3+
ADD COLUMN "access" INTEGER,
4+
ADD COLUMN "acronym" TEXT,
5+
ADD COLUMN "active" BOOLEAN NOT NULL DEFAULT true,
6+
ADD COLUMN "administrativeDependency" INTEGER,
7+
ADD COLUMN "availableArea" TEXT,
8+
ADD COLUMN "blockDiaryEntriesForClosedAcademicYears" BOOLEAN,
9+
ADD COLUMN "builtArea" TEXT,
10+
ADD COLUMN "condition" INTEGER,
11+
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
12+
ADD COLUMN "creationDecree" TEXT,
13+
ADD COLUMN "deletedAt" TIMESTAMP(3),
14+
ADD COLUMN "energyMeter" INTEGER,
15+
ADD COLUMN "floorType" INTEGER,
16+
ADD COLUMN "hasAEERoom" BOOLEAN,
17+
ADD COLUMN "hasAccessibleRestroom" BOOLEAN,
18+
ADD COLUMN "hasArtsRoom" BOOLEAN,
19+
ADD COLUMN "hasAuditorium" BOOLEAN,
20+
ADD COLUMN "hasCafeteria" BOOLEAN,
21+
ADD COLUMN "hasChildRestroom" BOOLEAN,
22+
ADD COLUMN "hasComputerLab" BOOLEAN,
23+
ADD COLUMN "hasCoveredCourt" BOOLEAN,
24+
ADD COLUMN "hasExternalArea" BOOLEAN,
25+
ADD COLUMN "hasGreenArea" BOOLEAN,
26+
ADD COLUMN "hasKitchen" BOOLEAN,
27+
ADD COLUMN "hasLibrary" BOOLEAN,
28+
ADD COLUMN "hasMultipurposeRoom" BOOLEAN,
29+
ADD COLUMN "hasNursery" BOOLEAN,
30+
ADD COLUMN "hasPERoom" BOOLEAN,
31+
ADD COLUMN "hasPantry" BOOLEAN,
32+
ADD COLUMN "hasPatio" BOOLEAN,
33+
ADD COLUMN "hasPlayground" BOOLEAN,
34+
ADD COLUMN "hasPrincipalOffice" BOOLEAN,
35+
ADD COLUMN "hasReadingRoom" BOOLEAN,
36+
ADD COLUMN "hasRestroomInside" BOOLEAN,
37+
ADD COLUMN "hasRestroomOutside" BOOLEAN,
38+
ADD COLUMN "hasScienceLab" BOOLEAN,
39+
ADD COLUMN "hasSecretaryOffice" BOOLEAN,
40+
ADD COLUMN "hasShower" BOOLEAN,
41+
ADD COLUMN "hasStudentDormitory" BOOLEAN,
42+
ADD COLUMN "hasTeacherDormitory" BOOLEAN,
43+
ADD COLUMN "hasTeachersRoom" BOOLEAN,
44+
ADD COLUMN "hasUncoveredCourt" BOOLEAN,
45+
ADD COLUMN "latitude" TEXT,
46+
ADD COLUMN "logoUrl" TEXT,
47+
ADD COLUMN "longitude" TEXT,
48+
ADD COLUMN "managerId" UUID,
49+
ADD COLUMN "managerPosition" TEXT,
50+
ADD COLUMN "numberOfFloors" INTEGER,
51+
ADD COLUMN "operationLocation" TEXT,
52+
ADD COLUMN "operationalStatus" INTEGER,
53+
ADD COLUMN "regulation" INTEGER,
54+
ADD COLUMN "sharedSchoolInepCode" INTEGER,
55+
ADD COLUMN "totalArea" TEXT,
56+
ADD COLUMN "waterConsumed" INTEGER;

prisma/schema.prisma

+67-12
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,73 @@ model Institution {
2020
}
2121

2222
model School {
23-
id String @id @default(uuid()) @db.Uuid
24-
name String
25-
address String?
26-
city String?
27-
state String?
28-
postalCode String?
29-
phone String?
30-
institutionId String @db.Uuid
31-
institution Institution @relation(fields: [institutionId], references: [id], onDelete: Restrict)
32-
courses Course[]
33-
timetables TimetableSchool[]
34-
teachers Teacher[]
23+
id String @id @default(uuid()) @db.Uuid
24+
name String
25+
address String?
26+
city String?
27+
state String?
28+
postalCode String?
29+
phone String?
30+
institutionId String @db.Uuid
31+
institution Institution @relation(fields: [institutionId], references: [id], onDelete: Restrict)
32+
courses Course[]
33+
timetables TimetableSchool[]
34+
teachers Teacher[]
35+
createdAt DateTime @default(now())
36+
deletedAt DateTime?
37+
active Boolean @default(true)
38+
abbreviation String?
39+
longitude String?
40+
latitude String?
41+
totalArea String?
42+
builtArea String?
43+
availableArea String?
44+
acronym String?
45+
blockDiaryEntriesForClosedAcademicYears Boolean?
46+
operationalStatus Int?
47+
administrativeDependency Int?
48+
regulation Int?
49+
logoUrl String?
50+
access Int?
51+
managerId String? @db.Uuid
52+
managerPosition String?
53+
operationLocation String?
54+
condition Int?
55+
sharedSchoolInepCode Int?
56+
creationDecree String?
57+
numberOfFloors Int?
58+
floorType Int?
59+
energyMeter Int?
60+
waterConsumed Int?
61+
hasPrincipalOffice Boolean?
62+
hasTeachersRoom Boolean?
63+
hasSecretaryOffice Boolean?
64+
hasComputerLab Boolean?
65+
hasScienceLab Boolean?
66+
hasAEERoom Boolean?
67+
hasCoveredCourt Boolean?
68+
hasUncoveredCourt Boolean?
69+
hasKitchen Boolean?
70+
hasLibrary Boolean?
71+
hasReadingRoom Boolean?
72+
hasPlayground Boolean?
73+
hasNursery Boolean?
74+
hasRestroomOutside Boolean?
75+
hasRestroomInside Boolean?
76+
hasChildRestroom Boolean?
77+
hasAccessibleRestroom Boolean?
78+
hasShower Boolean?
79+
hasCafeteria Boolean?
80+
hasPantry Boolean?
81+
hasAuditorium Boolean?
82+
hasPatio Boolean?
83+
hasGreenArea Boolean?
84+
hasPERoom Boolean?
85+
hasArtsRoom Boolean?
86+
hasStudentDormitory Boolean?
87+
hasTeacherDormitory Boolean?
88+
hasExternalArea Boolean?
89+
hasMultipurposeRoom Boolean?
3590
}
3691

3792
model Course {

prisma/seeds/seedInstitution.ts

+144-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,59 @@ export async function seedInstitution() {
2323
postalCode: '12345-678',
2424
phone: '(11) 8765-4321',
2525
institutionId: institution.id,
26+
active: true,
27+
abbreviation: 'EFA',
28+
longitude: '-46.6333',
29+
latitude: '-23.5505',
30+
totalArea: '5000',
31+
builtArea: '3000',
32+
availableArea: '2000',
33+
acronym: 'EFA',
34+
blockDiaryEntriesForClosedAcademicYears: false,
35+
operationalStatus: 1,
36+
administrativeDependency: 3,
37+
regulation: 1,
38+
logoUrl: 'https://example.com/logo1.png',
39+
access: 1,
40+
managerId: '1d3e4567-e89b-12d3-a456-426614174001',
41+
managerPosition: 'Principal',
42+
operationLocation: 'Urban',
43+
condition: 1,
44+
sharedSchoolInepCode: 12345678,
45+
creationDecree: 'Decreto 1234',
46+
numberOfFloors: 2,
47+
floorType: 1,
48+
energyMeter: 1,
49+
waterConsumed: 10000,
50+
hasPrincipalOffice: true,
51+
hasTeachersRoom: true,
52+
hasSecretaryOffice: true,
53+
hasComputerLab: true,
54+
hasScienceLab: true,
55+
hasAEERoom: false,
56+
hasCoveredCourt: true,
57+
hasUncoveredCourt: false,
58+
hasKitchen: true,
59+
hasLibrary: true,
60+
hasReadingRoom: true,
61+
hasPlayground: true,
62+
hasNursery: false,
63+
hasRestroomOutside: false,
64+
hasRestroomInside: true,
65+
hasChildRestroom: true,
66+
hasAccessibleRestroom: true,
67+
hasShower: false,
68+
hasCafeteria: true,
69+
hasPantry: true,
70+
hasAuditorium: false,
71+
hasPatio: true,
72+
hasGreenArea: true,
73+
hasPERoom: true,
74+
hasArtsRoom: false,
75+
hasStudentDormitory: false,
76+
hasTeacherDormitory: false,
77+
hasExternalArea: true,
78+
hasMultipurposeRoom: true,
2679
},
2780
})
2881

@@ -35,6 +88,59 @@ export async function seedInstitution() {
3588
postalCode: '98765-432',
3689
phone: '(21) 2345-6789',
3790
institutionId: institution.id,
91+
active: true,
92+
abbreviation: 'CB',
93+
longitude: '-43.2075',
94+
latitude: '-22.9028',
95+
totalArea: '7000',
96+
builtArea: '4500',
97+
availableArea: '2500',
98+
acronym: 'CB',
99+
blockDiaryEntriesForClosedAcademicYears: true,
100+
operationalStatus: 1,
101+
administrativeDependency: 3,
102+
regulation: 1,
103+
logoUrl: 'https://example.com/logo2.png',
104+
access: 1,
105+
managerId: '1d3e4567-e89b-12d3-a456-426614174002',
106+
managerPosition: 'Principal',
107+
operationLocation: 'Urban',
108+
condition: 1,
109+
sharedSchoolInepCode: 87654321,
110+
creationDecree: 'Decreto 5678',
111+
numberOfFloors: 3,
112+
floorType: 2,
113+
energyMeter: 2,
114+
waterConsumed: 15000,
115+
hasPrincipalOffice: true,
116+
hasTeachersRoom: true,
117+
hasSecretaryOffice: true,
118+
hasComputerLab: true,
119+
hasScienceLab: true,
120+
hasAEERoom: true,
121+
hasCoveredCourt: true,
122+
hasUncoveredCourt: true,
123+
hasKitchen: true,
124+
hasLibrary: true,
125+
hasReadingRoom: true,
126+
hasPlayground: true,
127+
hasNursery: true,
128+
hasRestroomOutside: true,
129+
hasRestroomInside: true,
130+
hasChildRestroom: true,
131+
hasAccessibleRestroom: true,
132+
hasShower: true,
133+
hasCafeteria: true,
134+
hasPantry: true,
135+
hasAuditorium: true,
136+
hasPatio: true,
137+
hasGreenArea: true,
138+
hasPERoom: true,
139+
hasArtsRoom: true,
140+
hasStudentDormitory: true,
141+
hasTeacherDormitory: true,
142+
hasExternalArea: true,
143+
hasMultipurposeRoom: true,
38144
},
39145
})
40146

@@ -219,6 +325,32 @@ export async function seedInstitution() {
219325
})
220326

221327
const timetable2 = await prisma.timetable.create({
328+
data: {
329+
name: 'Horário da Turma B',
330+
classroomId: classroom2.id,
331+
teachers: {
332+
connect: [{ id: teacher1.id }, { id: teacher2.id }],
333+
},
334+
classSessions: {
335+
create: [
336+
{
337+
dayOfWeek: 'WEDNESDAY',
338+
startTime: '08:00',
339+
endTime: '09:00',
340+
disciplineId: math.id,
341+
},
342+
{
343+
dayOfWeek: 'THURSDAY',
344+
startTime: '09:00',
345+
endTime: '10:00',
346+
disciplineId: science.id,
347+
},
348+
],
349+
},
350+
},
351+
})
352+
353+
const timetable3 = await prisma.timetable.create({
222354
data: {
223355
name: 'Horário da Turma C',
224356
classroomId: classroom3.id,
@@ -228,13 +360,13 @@ export async function seedInstitution() {
228360
classSessions: {
229361
create: [
230362
{
231-
dayOfWeek: 'WEDNESDAY',
363+
dayOfWeek: 'MONDAY',
232364
startTime: '10:00',
233365
endTime: '11:00',
234366
disciplineId: history.id,
235367
},
236368
{
237-
dayOfWeek: 'THURSDAY',
369+
dayOfWeek: 'TUESDAY',
238370
startTime: '11:00',
239371
endTime: '12:00',
240372
disciplineId: geography.id,
@@ -265,5 +397,15 @@ export async function seedInstitution() {
265397
geography,
266398
timetable1,
267399
timetable2,
400+
timetable3,
268401
})
269402
}
403+
404+
seedInstitution()
405+
.catch((e) => {
406+
console.error(e)
407+
process.exit(1)
408+
})
409+
.finally(async () => {
410+
await prisma.$disconnect()
411+
})

0 commit comments

Comments
 (0)