Create Residents table #78

Merged
BenjaminPalko merged 4 commits from 36-create-residents into master 2025-02-07 16:30:12 -05:00
BenjaminPalko commented 2025-02-03 17:37:00 -05:00 (Migrated from github.com)
No description provided.
netlify[bot] commented 2025-02-03 17:37:30 -05:00 (Migrated from github.com)

Deploy Preview for hestia-home ready!

Name Link
Latest commit 513cbee8e8
Latest deploy log https://app.netlify.com/sites/hestia-home/deploys/67a67a0bdb6d3c00084dd9dd
Deploy Preview https://deploy-preview-78--hestia-home.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

### <span aria-hidden="true">✅</span> Deploy Preview for *hestia-home* ready! | Name | Link | |:-:|------------------------| |<span aria-hidden="true">🔨</span> Latest commit | 513cbee8e8262c6758adb9f202f393f0030dc926 | |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/hestia-home/deploys/67a67a0bdb6d3c00084dd9dd | |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-78--hestia-home.netlify.app](https://deploy-preview-78--hestia-home.netlify.app) | |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTc4LS1oZXN0aWEtaG9tZS5uZXRsaWZ5LmFwcCJ9.-x01spSBsFPhE6qO74h2HULiumRivOrjtja-Dj1yB3g)<br /><br />_Use your smartphone camera to open QR code link._</details> | --- <!-- [hestia-home Preview](https://deploy-preview-78--hestia-home.netlify.app) --> _To edit notification comments on pull requests, go to your [Netlify site configuration](https://app.netlify.com/sites/hestia-home/configuration/notifications#deploy-webhooks)._
piopi (Migrated from github.com) reviewed 2025-02-05 13:19:14 -05:00
@ -34,0 +40,4 @@
phoneNumber String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
piopi (Migrated from github.com) commented 2025-02-04 08:51:39 -05:00

Missing the tenantId

Missing the tenantId
BenjaminPalko (Migrated from github.com) reviewed 2025-02-05 15:42:56 -05:00
@ -34,0 +40,4 @@
phoneNumber String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
BenjaminPalko (Migrated from github.com) commented 2025-02-05 15:42:56 -05:00

Fix, thanks!

Fix, thanks!
piopi (Migrated from github.com) reviewed 2025-02-05 16:19:15 -05:00
piopi (Migrated from github.com) commented 2025-02-05 16:19:15 -05:00

it should be required

it should be required
piopi (Migrated from github.com) reviewed 2025-02-05 16:19:19 -05:00
piopi (Migrated from github.com) commented 2025-02-05 16:19:18 -05:00

hmm why does it do an onDelete set null

hmm why does it do an onDelete set null
BenjaminPalko (Migrated from github.com) reviewed 2025-02-05 17:19:44 -05:00
BenjaminPalko (Migrated from github.com) commented 2025-02-05 17:19:44 -05:00
I believe this is normal https://github.com/prisma/prisma/issues/16228
piopi (Migrated from github.com) approved these changes 2025-02-06 13:50:09 -05:00
@ -0,0 +11,4 @@
);
-- AddForeignKey
ALTER TABLE "Resident" ADD CONSTRAINT "Resident_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
piopi (Migrated from github.com) commented 2025-02-06 13:50:05 -05:00

Feel like it should be ON DELETE CASACADE but maybe it is prisma generating this

Feel like it should be ON DELETE CASACADE but maybe it is prisma generating this
piopi (Migrated from github.com) commented 2025-02-05 17:30:41 -05:00

It shouldn't be unique

It shouldn't be unique
BenjaminPalko (Migrated from github.com) reviewed 2025-02-06 22:04:53 -05:00
@ -0,0 +11,4 @@
);
-- AddForeignKey
ALTER TABLE "Resident" ADD CONSTRAINT "Resident_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
BenjaminPalko (Migrated from github.com) commented 2025-02-06 22:04:53 -05:00

Cascade needs to be explicitly specified, I could see the desire to add that, but I can also see how it might be dangerous. If a tenant is accidentally deleted then it would cascade to all related tables and nuke a tenant completely, whereas with RESTRICT it would prevent this. Child tables would need to be removed FIRST before the parent, this would be a more explicit operation that would be less likely to be run on accident.

Thanks for coming to my Ted talk

Cascade needs to be explicitly specified, I could see the desire to add that, but I can also see how it might be dangerous. If a tenant is accidentally deleted then it would cascade to all related tables and nuke a tenant completely, whereas with RESTRICT it would prevent this. Child tables would need to be removed FIRST before the parent, this would be a more explicit operation that would be less likely to be run on accident. Thanks for coming to my Ted talk
DanMihailescu (Migrated from github.com) reviewed 2025-02-07 10:14:11 -05:00
@ -32,2 +32,4 @@
}
model Resident {
id String @id @default(uuid())
DanMihailescu (Migrated from github.com) commented 2025-02-07 10:11:32 -05:00

It should be marked as unique to ensure no duplicate residents

It should be marked as unique to ensure no duplicate residents
BenjaminPalko (Migrated from github.com) reviewed 2025-02-07 15:43:56 -05:00
@ -32,2 +32,4 @@
}
model Resident {
id String @id @default(uuid())
BenjaminPalko (Migrated from github.com) commented 2025-02-07 15:43:56 -05:00

@id is unique

@id is unique
piopi (Migrated from github.com) reviewed 2025-02-07 16:46:34 -05:00
@ -0,0 +11,4 @@
);
-- AddForeignKey
ALTER TABLE "Resident" ADD CONSTRAINT "Resident_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
piopi (Migrated from github.com) commented 2025-02-07 16:46:34 -05:00

If a tenant is deleted it means they want their data out of the platform. Not making it cascade delete just makes it harder to fully delete a tenant data. ( You could protect the data with an appropriate backup policy and db roles)

Cascade delete helps a lot when you setup your integration test and you delete your test tenant after each test, it makes the clean up of the test much easier.

If a tenant is deleted it means they want their data out of the platform. Not making it cascade delete just makes it harder to fully delete a tenant data. ( You could protect the data with an appropriate backup policy and db roles) Cascade delete helps a lot when you setup your integration test and you delete your test tenant after each test, it makes the clean up of the test much easier.
Sign in to join this conversation.
No description provided.