Get Started
PreviousNext

Database

Database management for the creatorem saas kit.

We are using Supabase to host our database.

Postgres Supabase Database

Every project is a full Postgres database, the world's most trusted relational database.

  • 100% portable
  • Built-in Auth with RLS
  • Easy to extend
  • Easy to extend

Why Supabase ?

Supabase is a modern PostgreSQL database platform that provides a lot of features out of the box. It is a great choice for a saas application.

Here are our favorite features :

FeatureDescription
✨ Row Level SecurityRLS allows you to control access to your database based on the user's role.
Api RESTSupabase provides a REST API to access and edit your database.
HostingSupabase Cloud provides affordable pricing and a free tier, perfect when you are just starting.
Open SourceIf you want to host your own database, you can host it yourself as Supabase is open source.
Web clientYou can view and edit your database in a Supabase Studio, a web interface to manage your database.
AuthenticationSupabase provides a built-in authentication system with many oAuth providers.
Much more...Version management, test, realtime database, bucket storage, etc...

sql is a language built to efficiently handle a huge amount of data. sql allows you to set more than tables and constraints. You can define functions, triggers, views, enums, etc...

Defining as much logic as possible using sql, you highly simplify your application logic. As all the data checking, control access, coercing, etc... are done by the database.

Project structure

By default, we have single database by monorepo. As the core of an appplication is its data, and the web/mobile/etc applications are closer to entry points to access and edit your data.

File/FolderDescription
migrationsAll migrations files. Do not touch, they are automatically generated using creatorem or supabase tools.
schemasThe most important files. Contains all the data logic declaration, tables, relations, etc...
env-schemasThat files contains examples of tables definition that you might use in your products. Can be used in dev environment to generate migrations.
testsSupabase test files.
.envThe environment variables for the database.
config.tomlThe config file for the database. Allow you to configure the supabase database on environment variables. For example, you can set oAuth providers here.
seed.sqlTo seed the database with some data.
20250817141810_generated_from_schemas.sql
booking.sql
000-privileges.sql
001-enums.sql
nnn-other-schemas.sql
.env
config.toml
seed.sql
package.json
turbo.json

Migration generation

To assemble the migration file, you can use the following command :

pnpm db:generate-migration

If you start with an empty project, you may want example tables to see all the kit power in action.

You can also create your migration with the example booking.sql file in the supabase/env-schemas folder using the following command :

pnpm db:generate-migration --env-schemas booking

Commands

Start

First, make sure that docker is running.

pnpm supabase:start

Stop

pnpm supabase:stop

Test

pnpm supabase:test

Reset

The reset command will rebuild the migration file and recreate a new empty database instance.

pnpm db:reset

If you want to reset with the example booking.sql schema, you can use the following command :

pnpm db:reset:booking

Types generation

pnpm db:types

That command will :

  • generate the supabase types in the kit/db/core/src/database.types.ts file.
  • generate the drizzle declaration files in the @kit/drizzle/src/drizzle/ package.
  • create extra types in the @kit/drizzle/src/tables.ts file to improve a cleaner development experience.

Dump

pnpm supabase:db:dump:local

Deploy

pnpm supabase:deploy

How is this guide?

Last updated on 10/17/2025