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

Commit

Permalink
chore: impronvments for model school
Browse files Browse the repository at this point in the history
  • Loading branch information
hermesalvesbr committed May 26, 2024
1 parent 1e4ba79 commit 7f8f539
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Docker/custom-postgresql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
shared_preload_libraries=timescaledb
8 changes: 4 additions & 4 deletions Docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: '3.8'

services:
timescaledb:
eduprime_db:
image: timescale/timescaledb:latest-pg16
container_name: eduprime-db
container_name: eduprime_db
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
Expand All @@ -14,7 +14,7 @@ services:
ports:
- '5432:5432'
volumes:
- timescaledb_data:/var/lib/postgresql/data
- eduprime_db_data:/var/lib/postgresql/data
- ./custom-postgresql.conf:/etc/postgresql/postgresql.conf
entrypoint: >
sh -c "apk add --no-cache tzdata &&
Expand All @@ -23,4 +23,4 @@ services:
echo 'shared_preload_libraries=timescaledb' >> /etc/postgresql/postgresql.conf &&
exec docker-entrypoint.sh postgres"
volumes:
timescaledb_data:
eduprime_db_data:
56 changes: 56 additions & 0 deletions prisma/migrations/20240526202041_add_school_columns/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- AlterTable
ALTER TABLE "School" ADD COLUMN "abbreviation" TEXT,
ADD COLUMN "access" INTEGER,
ADD COLUMN "acronym" TEXT,
ADD COLUMN "active" BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN "administrativeDependency" INTEGER,
ADD COLUMN "availableArea" TEXT,
ADD COLUMN "blockDiaryEntriesForClosedAcademicYears" BOOLEAN,
ADD COLUMN "builtArea" TEXT,
ADD COLUMN "condition" INTEGER,
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "creationDecree" TEXT,
ADD COLUMN "deletedAt" TIMESTAMP(3),
ADD COLUMN "energyMeter" INTEGER,
ADD COLUMN "floorType" INTEGER,
ADD COLUMN "hasAEERoom" BOOLEAN,
ADD COLUMN "hasAccessibleRestroom" BOOLEAN,
ADD COLUMN "hasArtsRoom" BOOLEAN,
ADD COLUMN "hasAuditorium" BOOLEAN,
ADD COLUMN "hasCafeteria" BOOLEAN,
ADD COLUMN "hasChildRestroom" BOOLEAN,
ADD COLUMN "hasComputerLab" BOOLEAN,
ADD COLUMN "hasCoveredCourt" BOOLEAN,
ADD COLUMN "hasExternalArea" BOOLEAN,
ADD COLUMN "hasGreenArea" BOOLEAN,
ADD COLUMN "hasKitchen" BOOLEAN,
ADD COLUMN "hasLibrary" BOOLEAN,
ADD COLUMN "hasMultipurposeRoom" BOOLEAN,
ADD COLUMN "hasNursery" BOOLEAN,
ADD COLUMN "hasPERoom" BOOLEAN,
ADD COLUMN "hasPantry" BOOLEAN,
ADD COLUMN "hasPatio" BOOLEAN,
ADD COLUMN "hasPlayground" BOOLEAN,
ADD COLUMN "hasPrincipalOffice" BOOLEAN,
ADD COLUMN "hasReadingRoom" BOOLEAN,
ADD COLUMN "hasRestroomInside" BOOLEAN,
ADD COLUMN "hasRestroomOutside" BOOLEAN,
ADD COLUMN "hasScienceLab" BOOLEAN,
ADD COLUMN "hasSecretaryOffice" BOOLEAN,
ADD COLUMN "hasShower" BOOLEAN,
ADD COLUMN "hasStudentDormitory" BOOLEAN,
ADD COLUMN "hasTeacherDormitory" BOOLEAN,
ADD COLUMN "hasTeachersRoom" BOOLEAN,
ADD COLUMN "hasUncoveredCourt" BOOLEAN,
ADD COLUMN "latitude" TEXT,
ADD COLUMN "logoUrl" TEXT,
ADD COLUMN "longitude" TEXT,
ADD COLUMN "managerId" UUID,
ADD COLUMN "managerPosition" TEXT,
ADD COLUMN "numberOfFloors" INTEGER,
ADD COLUMN "operationLocation" TEXT,
ADD COLUMN "operationalStatus" INTEGER,
ADD COLUMN "regulation" INTEGER,
ADD COLUMN "sharedSchoolInepCode" INTEGER,
ADD COLUMN "totalArea" TEXT,
ADD COLUMN "waterConsumed" INTEGER;
79 changes: 67 additions & 12 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,73 @@ model Institution {
}

model School {
id String @id @default(uuid()) @db.Uuid
name String
address String?
city String?
state String?
postalCode String?
phone String?
institutionId String @db.Uuid
institution Institution @relation(fields: [institutionId], references: [id], onDelete: Restrict)
courses Course[]
timetables TimetableSchool[]
teachers Teacher[]
id String @id @default(uuid()) @db.Uuid
name String
address String?
city String?
state String?
postalCode String?
phone String?
institutionId String @db.Uuid
institution Institution @relation(fields: [institutionId], references: [id], onDelete: Restrict)
courses Course[]
timetables TimetableSchool[]
teachers Teacher[]
createdAt DateTime @default(now())
deletedAt DateTime?
active Boolean @default(true)
abbreviation String?
longitude String?
latitude String?
totalArea String?
builtArea String?
availableArea String?
acronym String?
blockDiaryEntriesForClosedAcademicYears Boolean?
operationalStatus Int?
administrativeDependency Int?
regulation Int?
logoUrl String?
access Int?
managerId String? @db.Uuid
managerPosition String?
operationLocation String?
condition Int?
sharedSchoolInepCode Int?
creationDecree String?
numberOfFloors Int?
floorType Int?
energyMeter Int?
waterConsumed Int?
hasPrincipalOffice Boolean?
hasTeachersRoom Boolean?
hasSecretaryOffice Boolean?
hasComputerLab Boolean?
hasScienceLab Boolean?
hasAEERoom Boolean?
hasCoveredCourt Boolean?
hasUncoveredCourt Boolean?
hasKitchen Boolean?
hasLibrary Boolean?
hasReadingRoom Boolean?
hasPlayground Boolean?
hasNursery Boolean?
hasRestroomOutside Boolean?
hasRestroomInside Boolean?
hasChildRestroom Boolean?
hasAccessibleRestroom Boolean?
hasShower Boolean?
hasCafeteria Boolean?
hasPantry Boolean?
hasAuditorium Boolean?
hasPatio Boolean?
hasGreenArea Boolean?
hasPERoom Boolean?
hasArtsRoom Boolean?
hasStudentDormitory Boolean?
hasTeacherDormitory Boolean?
hasExternalArea Boolean?
hasMultipurposeRoom Boolean?
}

model Course {
Expand Down
146 changes: 144 additions & 2 deletions prisma/seeds/seedInstitution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,59 @@ export async function seedInstitution() {
postalCode: '12345-678',
phone: '(11) 8765-4321',
institutionId: institution.id,
active: true,
abbreviation: 'EFA',
longitude: '-46.6333',
latitude: '-23.5505',
totalArea: '5000',
builtArea: '3000',
availableArea: '2000',
acronym: 'EFA',
blockDiaryEntriesForClosedAcademicYears: false,
operationalStatus: 1,
administrativeDependency: 3,
regulation: 1,
logoUrl: 'https://example.com/logo1.png',
access: 1,
managerId: '1d3e4567-e89b-12d3-a456-426614174001',
managerPosition: 'Principal',
operationLocation: 'Urban',
condition: 1,
sharedSchoolInepCode: 12345678,
creationDecree: 'Decreto 1234',
numberOfFloors: 2,
floorType: 1,
energyMeter: 1,
waterConsumed: 10000,
hasPrincipalOffice: true,
hasTeachersRoom: true,
hasSecretaryOffice: true,
hasComputerLab: true,
hasScienceLab: true,
hasAEERoom: false,
hasCoveredCourt: true,
hasUncoveredCourt: false,
hasKitchen: true,
hasLibrary: true,
hasReadingRoom: true,
hasPlayground: true,
hasNursery: false,
hasRestroomOutside: false,
hasRestroomInside: true,
hasChildRestroom: true,
hasAccessibleRestroom: true,
hasShower: false,
hasCafeteria: true,
hasPantry: true,
hasAuditorium: false,
hasPatio: true,
hasGreenArea: true,
hasPERoom: true,
hasArtsRoom: false,
hasStudentDormitory: false,
hasTeacherDormitory: false,
hasExternalArea: true,
hasMultipurposeRoom: true,
},
})

Expand All @@ -35,6 +88,59 @@ export async function seedInstitution() {
postalCode: '98765-432',
phone: '(21) 2345-6789',
institutionId: institution.id,
active: true,
abbreviation: 'CB',
longitude: '-43.2075',
latitude: '-22.9028',
totalArea: '7000',
builtArea: '4500',
availableArea: '2500',
acronym: 'CB',
blockDiaryEntriesForClosedAcademicYears: true,
operationalStatus: 1,
administrativeDependency: 3,
regulation: 1,
logoUrl: 'https://example.com/logo2.png',
access: 1,
managerId: '1d3e4567-e89b-12d3-a456-426614174002',
managerPosition: 'Principal',
operationLocation: 'Urban',
condition: 1,
sharedSchoolInepCode: 87654321,
creationDecree: 'Decreto 5678',
numberOfFloors: 3,
floorType: 2,
energyMeter: 2,
waterConsumed: 15000,
hasPrincipalOffice: true,
hasTeachersRoom: true,
hasSecretaryOffice: true,
hasComputerLab: true,
hasScienceLab: true,
hasAEERoom: true,
hasCoveredCourt: true,
hasUncoveredCourt: true,
hasKitchen: true,
hasLibrary: true,
hasReadingRoom: true,
hasPlayground: true,
hasNursery: true,
hasRestroomOutside: true,
hasRestroomInside: true,
hasChildRestroom: true,
hasAccessibleRestroom: true,
hasShower: true,
hasCafeteria: true,
hasPantry: true,
hasAuditorium: true,
hasPatio: true,
hasGreenArea: true,
hasPERoom: true,
hasArtsRoom: true,
hasStudentDormitory: true,
hasTeacherDormitory: true,
hasExternalArea: true,
hasMultipurposeRoom: true,
},
})

Expand Down Expand Up @@ -219,6 +325,32 @@ export async function seedInstitution() {
})

const timetable2 = await prisma.timetable.create({
data: {
name: 'Horário da Turma B',
classroomId: classroom2.id,
teachers: {
connect: [{ id: teacher1.id }, { id: teacher2.id }],
},
classSessions: {
create: [
{
dayOfWeek: 'WEDNESDAY',
startTime: '08:00',
endTime: '09:00',
disciplineId: math.id,
},
{
dayOfWeek: 'THURSDAY',
startTime: '09:00',
endTime: '10:00',
disciplineId: science.id,
},
],
},
},
})

const timetable3 = await prisma.timetable.create({
data: {
name: 'Horário da Turma C',
classroomId: classroom3.id,
Expand All @@ -228,13 +360,13 @@ export async function seedInstitution() {
classSessions: {
create: [
{
dayOfWeek: 'WEDNESDAY',
dayOfWeek: 'MONDAY',
startTime: '10:00',
endTime: '11:00',
disciplineId: history.id,
},
{
dayOfWeek: 'THURSDAY',
dayOfWeek: 'TUESDAY',
startTime: '11:00',
endTime: '12:00',
disciplineId: geography.id,
Expand Down Expand Up @@ -265,5 +397,15 @@ export async function seedInstitution() {
geography,
timetable1,
timetable2,
timetable3,
})
}

seedInstitution()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})

0 comments on commit 7f8f539

Please sign in to comment.