Drizzle
Use an evertap PostgreSQL or MySQL database with Drizzle ORM and Drizzle Kit, from the URL in .env to migrations and a database for tests.
Drizzle connects with the URL evertap gives each database, through the same drivers it uses
anywhere else: node-postgres for PostgreSQL and mysql2 for MySQL.
Create the database
evertap create postgres myapp # or: evertap create mysql myapp
evertap env myapp >> .env.env gains the URL:
DATABASE_URL=postgres://evertap_k3x9q2m7v1ab:…@ev.internal:5432/evertap_k3x9q2m7v1abOn a laptop that reaches evertap on another machine, keep evertap connect running while you work
(Connect from your laptop).
Point Drizzle Kit at it
In drizzle.config.ts:
import "dotenv/config";
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql", // or "mysql"
schema: "./src/db/schema.ts",
dbCredentials: { url: process.env.DATABASE_URL! },
});Connect from your app
import { drizzle } from "drizzle-orm/node-postgres";
export const db = drizzle(process.env.DATABASE_URL!);Migrate
npx drizzle-kit generate
npx drizzle-kit migratenpx drizzle-kit push applies the schema directly instead, without migration files.
Tests
Drizzle Kit does not create databases. Create a second database for tests and run them with its
URL; dotenv leaves a variable you set on the command line as it is.
evertap create postgres myapp-test
DATABASE_URL="$(evertap url myapp-test)" npx drizzle-kit migrate
DATABASE_URL="$(evertap url myapp-test)" npm testThe user in the URL can also create databases, so tests can make one per worker with
CREATE DATABASE. In CI, create the test database with --temporary and an API key
(CI with an API key).
Good to know
- evertap does not offer PostgreSQL's own TLS. Leave
sslmodeout of the URL, or set it todisable;sslmode=requirefails. - Through
evertap connect, connections can drop when evertap restarts or your network changes. Have the pool replace them after about 30 minutes:drizzle({ connection: { connectionString: process.env.DATABASE_URL!, maxLifetimeSeconds: 1800 } })(Connection pools).
The evertap name and logo are not licensed with the code (section 6 of the license). You may use them to refer to evertap, but not to name or brand your own product or service, or in a way that suggests evertap made or endorses it, without permission.
evertap is an independent project. It is not affiliated with, endorsed, sponsored, supported, or certified by the owners of the software it runs, and it uses their names only to say which software that is.
- Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.
- MySQL is a registered trademark of Oracle and/or its affiliates.
- Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd.
- Other names, including Garage and Cloudflare, may be trademarks of their respective owners.
Prisma
Use an evertap PostgreSQL or MySQL database with Prisma ORM 7. migrate dev creates its shadow database by itself, with no second URL to set.
Ruby on Rails
Use an evertap PostgreSQL or MySQL database with Rails, with database.yml, migrations, and a test database that stays apart from your development data.