diff --git a/prisma/migrations/20250206142847_add_residents/migration.sql b/prisma/migrations/20250206142847_add_residents/migration.sql new file mode 100644 index 0000000..ed6192f --- /dev/null +++ b/prisma/migrations/20250206142847_add_residents/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "Resident" ( + "id" TEXT NOT NULL, + "tenantId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "phoneNumber" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Resident_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Resident" ADD CONSTRAINT "Resident_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index fbffa92..648c57f 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) +# It should be added in your version-control system (e.g., Git) provider = "postgresql" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 68d49c9..4adba1e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -31,11 +31,24 @@ model User { @@unique([clerkId, tenantId]) } +model Resident { + id String @id @default(uuid()) + tenant Tenant @relation(fields: [tenantId], references: [id]) + tenantId String + + name String + phoneNumber String + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + model Tenant { id String @id @default(uuid()) clerkOrganizationId String @unique users User[] + residents Resident[] tenantConfig TenantConfig? name String