diff --git a/Docker/custom-postgresql.conf b/Docker/custom-postgresql.conf index 420ff02..017e6b8 100644 --- a/Docker/custom-postgresql.conf +++ b/Docker/custom-postgresql.conf @@ -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 diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index 392513b..141a2fb 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -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} @@ -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 && @@ -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: diff --git a/prisma/migrations/20240526202041_add_school_columns/migration.sql b/prisma/migrations/20240526202041_add_school_columns/migration.sql new file mode 100644 index 0000000..776666a --- /dev/null +++ b/prisma/migrations/20240526202041_add_school_columns/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b0c3038..36f393e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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 { diff --git a/prisma/seeds/seedInstitution.ts b/prisma/seeds/seedInstitution.ts index d8e1b00..2294a88 100644 --- a/prisma/seeds/seedInstitution.ts +++ b/prisma/seeds/seedInstitution.ts @@ -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, }, }) @@ -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, }, }) @@ -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, @@ -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, @@ -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() + })