PostgreSQL
PostgreSQL is a powerful, open-source relational database management system known for its advanced features, extensibility, and support for complex queries and large datasets. Read more here.
Example Usage
Make sure you have PostgreSQL installed and configured. Then, you can connect it straight into Faire Auth.
import { faireAuth } from "faire-auth";
import { Pool } from "pg";
export const auth = faireAuth({
database: new Pool({
connectionString: "postgres://user:password@localhost:5432/database",
}),
});For more information, read Kysely's documentation to the PostgresDialect.
Schema generation & migration
The Faire Auth CLI allows you to generate or migrate your database schema based on your Faire Auth configuration and plugins.
PostgreSQL Schema Generation | PostgreSQL Schema Migration |
|---|---|
| ✅ Supported | ✅ Supported |
npx @faire-auth/cli@latest generatenpx @faire-auth/cli@latest migrateUse a non-default schema
In most cases, the default schema is public. To have Faire Auth use a
non-default schema (e.g., auth) for its tables,
set the PostgreSQL user's default schema before generating or migrating:
ALTER USER authuser SET SEARCH_PATH TO auth;alternatively, append the option to your connection URI, for example:
postgres://<DATABASE_URL>?option=-c search_path=authURL-encode if needed: ?option=-c%20search_path%3Dauth.
Ensure the target schema exists and the database user has the required permissions.
Additional Information
PostgreSQL is supported under the hood via the Kysely adapter, any database supported by Kysely would also be supported. (Read more here)
If you're looking for performance improvements or tips, take a look at our guide to performance optimizations.