Skip to content

Migrate from Prisma Python to Piccolo#190

Merged
MMK21Hub merged 36 commits into
hackclub:mainfrom
MMK21Hub:piccolo
Apr 29, 2026
Merged

Migrate from Prisma Python to Piccolo#190
MMK21Hub merged 36 commits into
hackclub:mainfrom
MMK21Hub:piccolo

Conversation

@MMK21Hub
Copy link
Copy Markdown
Collaborator

@MMK21Hub MMK21Hub commented Apr 21, 2026

This PR gets rid of Prisma (see #120) and adopts Piccolo as our ORM.

It also adds support for database migrations so we can properly manage changes we make to the database.

TODO: Work out how and when we're going to run the DB migrations. Done!

EDRipper added a commit to EDRipper/nephthys that referenced this pull request Apr 23, 2026
EDRipper added a commit to EDRipper/nephthys that referenced this pull request Apr 23, 2026
MMK21Hub and others added 6 commits April 24, 2026 16:45
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
MMK21Hub pushed a commit to MMK21Hub/nephthys that referenced this pull request Apr 28, 2026
* Add Beest (hackclub#190)

* Fix [transcripts]: grammar correction

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update nephthys/transcripts/transcripts/beest.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update nephthys/transcripts/transcripts/beest.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update nephthys/transcripts/transcripts/beest.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
@MMK21Hub MMK21Hub marked this pull request as ready for review April 28, 2026 20:39
Copilot AI review requested due to automatic review settings April 28, 2026 20:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Nephthys from the unmaintained Prisma Python client to the Piccolo ORM, introducing a Piccolo-backed schema plus a migration workflow and updating all DB access paths accordingly.

Changes:

  • Replace Prisma dependency and schema with Piccolo tables + configuration.
  • Update DB queries across actions/events/tasks/views/macros to use Piccolo’s async APIs and snake_case fields.
  • Add Piccolo migrations and container startup wiring to run migrations on boot.

Reviewed changes

Copilot reviewed 64 out of 66 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
pyproject.toml Swap Prisma dependency for Piccolo (Postgres + uvloop extras).
prisma/schema.prisma Remove legacy Prisma schema.
piccolo_conf.py Add Piccolo engine + app registry configuration.
nephthys/piccolo_app.py Register Piccolo app config (tables + migrations folder).
nephthys/piccolo_migrations/init.py Initialize migrations package.
nephthys/piccolo_migrations/nephthys_010_init.py Introduce initial SQL migration for legacy-compatible schema.
nephthys/piccolo_migrations/nephthys_011_timestamp_to_timestamptz.py Convert legacy TIMESTAMP columns to TIMESTAMPTZ.
nephthys/piccolo_migrations/nephthys_012_snake_case_type_names.py Rename legacy enum types to snake_case.
nephthys/database/enums.py Add TicketStatus/UserType enums + Piccolo column wrappers.
nephthys/database/postgres_enum.py Add custom Piccolo column factory for Postgres enums.
nephthys/database/tables.py Define Piccolo table models mapping to legacy column names.
nephthys/main.py Start/stop Piccolo connection pool; adjust imports/startup flow.
nephthys/utils/env.py Remove Prisma client initialization from environment config.
nephthys/utils/starlette.py Update health/metrics endpoints to remove Prisma health/metrics.
nephthys/utils/permissions.py Switch ticket lookup for permission checks to Piccolo.
nephthys/utils/old_tickets.py Port unanswered ticket query logic to Piccolo.
nephthys/utils/ticket_methods.py Port bot message persistence / ticket deletes to Piccolo.
nephthys/utils/stats.py Port stats calculations to Piccolo (leaderboards/counting).
nephthys/events/message_creation.py Port ticket creation, thread handling, user upsert, and tag lookup to Piccolo.
nephthys/events/message_deletion.py Port ticket lookup/deletion on Slack message deletion to Piccolo.
nephthys/events/message/send_backend_message.py Port category tag loading + user fields to Piccolo models.
nephthys/events/app_home_opened.py Port Slack user DB lookup to Piccolo.
nephthys/events/channel_left.py Port helper flag update to Piccolo.
nephthys/views/home/dashboard.py Update User model import to Piccolo table.
nephthys/views/home/stats.py Update User model import to Piccolo table.
nephthys/views/home/category_tags.py Port category tags query to Piccolo.
nephthys/views/home/team_tags.py Port team tags/subscriptions view to Piccolo.
nephthys/views/home/assigned.py Port assigned ticket query + field names to Piccolo.
nephthys/views/home/components/header.py Update User model import to Piccolo table.
nephthys/views/home/components/leaderboards.py Update Slack ID field name for leaderboard rendering.
nephthys/views/home/components/ticket_status_pie.py Port ticket counts queries + enum import to Piccolo.
nephthys/options/team_tags.py Port tag options provider to Piccolo.
nephthys/options/category_tags.py Port category tag options provider to Piccolo.
nephthys/tasks/update_helpers.py Port helper sync job to Piccolo updates/inserts.
nephthys/tasks/fulfillment_reminder.py Port fulfillment reminder ticket query + tag lookups to Piccolo.
nephthys/tasks/daily_stats.py Port daily stats task tag lookups + fields to Piccolo.
nephthys/tasks/close_stale.py Port stale-ticket closing logic and relations to Piccolo.
nephthys/scripts/add_dummy_data.py Port dummy ticket creation to Piccolo saves.
nephthys/api/user.py Port per-user stats endpoint to Piccolo counts.
nephthys/api/tickets.py Port tickets listing endpoint to Piccolo queries + tag loading.
nephthys/api/ticket.py Port single ticket endpoint + JSON serialization to Piccolo model fields.
nephthys/api/stats.py Update Slack ID field name in API payload.
nephthys/commands/dm_magic_link.py Port helper permission check to Piccolo user lookup.
nephthys/actions/resolve.py Port resolve action (permission checks, ticket update) to Piccolo.
nephthys/actions/tag_subscribe.py Port tag subscription create/delete to Piccolo.
nephthys/actions/create_team_tag.py Port team tag creation/admin check to Piccolo.
nephthys/actions/create_category_tag.py Port category tag creation/admin check to Piccolo.
nephthys/actions/assign_team_tag.py Port backend tag assignment + subscriber notification to Piccolo.
nephthys/actions/assign_category_tag.py Port category tag assignment + backend message update to Piccolo.
nephthys/macros/init.py Update macro runner to use Piccolo models/enums.
nephthys/macros/types.py Adjust macro base logic for Piccolo FK/object behavior.
nephthys/macros/resolve.py Port resolve macro fields to Piccolo.
nephthys/macros/reopen.py Port reopen macro updates/fields to Piccolo.
nephthys/macros/thread.py Port thread macro to Piccolo fields/queries.
nephthys/macros/team_tag.py Port ?tag macro to Piccolo tables and fields.
nephthys/macros/hackatime.py Port hackatime macro to Piccolo fields/queries.
nephthys/macros/shipcertqueue.py Port ship queue macro to Piccolo fields/queries.
nephthys/macros/hello_world.py Update helper Slack ID field name.
nephthys/macros/trigger_daily_stats.py Update helper/ticket field names.
nephthys/macros/trigger_fulfillment_reminder.py Update helper/ticket field names.
entrypoint.sh Add startup migrations step (configurable via RUN_MIGRATIONS).
Dockerfile Remove Prisma db push; run entrypoint script; keep healthcheck.
.dockerignore Ignore dev data directory.
.vscode/settings.json Remove Prisma-specific VS Code setting.
docs/contributing.md Add general style guidelines and Slack channel pointer.
Comments suppressed due to low confidence (1)

nephthys/views/home/team_tags.py:58

  • subs is a list of Slack IDs (subs = [u.slack_id for u in sub_users]), but later you check user.id not in subs and set the button text/style based on that. Since user.id is an int, this condition will always be true, so the UI will always show “subscribe”. Compare against user.slack_id or against the integer sub_user_ids instead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nephthys/utils/stats.py
Comment thread nephthys/utils/stats.py
Comment thread nephthys/views/home/team_tags.py
Comment thread nephthys/piccolo_migrations/nephthys_012_snake_case_type_names.py
Comment thread nephthys/macros/thread.py
Comment thread nephthys/macros/hackatime.py
Comment thread nephthys/actions/assign_category_tag.py
Comment thread nephthys/actions/create_category_tag.py Outdated
Comment thread Dockerfile
Comment thread nephthys/piccolo_migrations/nephthys_010_init.py
Copilot AI review requested due to automatic review settings April 29, 2026 15:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 64 out of 66 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nephthys/utils/stats.py
Comment thread nephthys/tasks/daily_stats.py
Comment thread nephthys/piccolo_migrations/nephthys_012_snake_case_type_names.py
Comment thread nephthys/api/ticket.py Outdated
Comment thread nephthys/tasks/fulfillment_reminder.py
Comment thread nephthys/macros/shipcertqueue.py
Comment thread nephthys/database/tables.py
MMK21Hub and others added 2 commits April 29, 2026 16:44
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 15:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 64 out of 66 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nephthys/__main__.py
Comment thread nephthys/utils/stats.py
Comment thread nephthys/utils/stats.py
@MMK21Hub MMK21Hub added this pull request to the merge queue Apr 29, 2026
Merged via the queue into hackclub:main with commit 1c2d118 Apr 29, 2026
8 checks passed
@MMK21Hub MMK21Hub deleted the piccolo branch April 29, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants