Create a new project (or clone our example project)
Configure your environment
tenants
table, which is used to store tenant information.
Therefore, we recommend first pulling in the built-in tables to your project, and
then starting to build your own tables.
Pull in the built-in tables
schema.prisma
file with the built-in tenants
table.Generate Prisma client
Add your own tables
schema.prisma
file and add your own models. For example:Push changes to the database
db pull
and db push
work well in development, where you can evolve the schema without tracking every change.
However, in production, we recommend using tracked migrations to ensure that the schema is always
in sync with the code.
Because Nile has a built-in tenants
table, we first create a baseline migration that will include the built-in tables,
and then create additional migrations for our own tables.
Create a baseline migration
Apply the baseline migration
Create a migration for your own tables
posts
table to schema.prisma
.
If you already have this table in your schema, you can add a column instead.datasource
) with the new schema in schema.prisma
(the datamodel
).While both the datasource
and datamodel
are in the same file, the first will refer to the
datasource
definition in the schema.prisma
file while the second will refer to the model itself.npx prisma migrate dev
. However, this will not work
for Nile because the npx prisma migrate dev
command starts by attempting to “reset” a shadow database by dropping all tables.
This is not possible in Nile because the built-in tables are required for core functionality.Apply the migration