Prisma TimescaleDB
To set up a prisma timescaledb workflow, point your schema to a PostgreSQL instance with the time-series extension turned on. Then run blank migration scripts to build hypertables with raw SQL commands. Engineering teams often use one shared database user for both daily app queries and schema updates. This broad role lets any service or person run drop commands or read raw customer rows. How a prisma timescaledb setup works TimescaleDB runs as an extension inside a standard PostgreSQL databas
Prisma Cloud Compliance: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To set up a prisma timescaledb workflow, point your schema to a PostgreSQL instance with the time-series extension turned on. Then run blank migration scripts to build hypertables with raw SQL commands. Engineering teams often use one shared database user for both daily app queries and schema updates. This broad role lets any service or person run drop commands or read raw customer rows.
How a prisma timescaledb setup works
TimescaleDB runs as an extension inside a standard PostgreSQL database engine. The ORM treats this database just like a normal relational store. You define your data models in a central schema file. Each time-series table needs a time column as part of its primary key. A compound key with a timestamp and a device ID works well.
The ORM does not know how to create hypertables on its own. Hypertables are special tables that split time-series data into smaller chunks by time. To set them up, you first generate an empty migration file. Next, you write a custom SQL call inside that file to convert the standard table. When your deployment pipeline runs the migration tool, PostgreSQL executes that SQL function. From that point on, your app writes and reads rows using standard client methods.
Continuous aggregates also need manual steps during your schema updates. You create these views in raw SQL migration files to pre-calculate time-bucket metrics. Next, you add a read-only view block or model in your schema file. This step gives your backend code type-safe read methods for those rollups.
Managing database roles for migrations and queries
Running schema changes requires high database permissions on the target server. The user account running the migration must own the tables and call extension functions. Daily app queries only need to insert new events and read old metrics. Many teams skip role separation and give the main app user full admin rights.
A safer approach splits these duties into two distinct PostgreSQL roles. You create one admin role for the build pipeline to run migration files. You create a second limited role for the running app to read and write rows. You also set up read-only accounts for engineers who debug production issues.
Prisma Cloud Compliance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Even with separate roles, teams still store database passwords in local files or build tools. Developers often copy these keys to run manual queries or check migration states from their laptops. Once a user logs in, PostgreSQL grants full permissions for that role across every table.
What native database roles leave open
Native database roles decide who can log in and which tables they can touch. They do not inspect what individual queries do while a session is active. If an engineer logs in with a migration role to fix an index, nothing stops an accidental table drop.
Time-series tables also hold user metadata alongside metric values. A support engineer checking event logs might pull rows that contain emails, phone numbers, or card numbers. Standard PostgreSQL permissions work at the table or column level, not on live result sets. If a role needs to read a JSON payload column, it sees every field inside that payload. Native logs also require heavy server flags to track who ran which query during an incident.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can the ORM create hypertables without raw SQL migrations?
No, the schema language does not have native tags for time-series hypertables. You must generate a migration file and add the SQL conversion function by hand.
How should we set up primary keys for time-series models?
Time-series partitions require the timestamp column in any unique index or primary key. Use a composite key that pairs your time column with an entity ID.
Why should we separate migration users from app users?
Migrations need owner rights to alter tables and manage database extensions. Keeping your live app on a restricted role prevents code bugs from dropping production tables.
Related guides
In this post