Prisma Multi Tenant Versions Save

🧭 Use Prisma as a multi-tenant provider for your application

2.4.2

3 years ago

This version fixes a small bug with Windows and directories with spaces

2.4.1

3 years ago

In this release:

  • Upgraded Prisma version
  • Removal of the Nexus plugin
  • Some bug fixes

Upgraded Prisma version

This version of Prisma-multi-tenant now comes with Prisma v2.10.1. (See Prisma release notes)

Removal of the Nexus plugin

Unfortunately, Nexus Framework has been deprecated. (See deprecation notice). Therefore, we removed the Nexus plugin and its documentation from the repository

Bug fixes

  • Allow quotes surrounding urls #60
  • Fix "plurals" bug on init
  • Fix missing "find-up" bug

2.3.1

3 years ago

In this release:

  • Upgraded Prisma version
  • A new Redwood plugin
  • Allow --schema option
  • More documentation & small stuff

Upgraded Prisma version

This version of Prisma-multi-tenant now comes with Prisma v2.4.1. (See Prisma release notes)

A new Redwood plugin

Redwood is a Framework "Bringing full-stack to the Jamstack", using Prisma to handle your database.

This release introduce a new Redwood plugin, @prisma-multi-tenant/redwood, which adds multi-tenancy:

api/src/lib/db.js:

import { MultiTenant, fromContext } from '@prisma-multi-tenant/redwood'

export const multiTenant = new MultiTenant()
export const db = fromContext()

api/src/functions/graphql.js:

import { multiTenant } from 'src/lib/db'

export const handler = createGraphQLHandler({
  schema: makeMergedSchema({
    schemas,
    services: makeServices({ services }),
  }),
  context: async ({ event }) => ({
    // The name can come from anywhere (headers, token, ...)
    db: await multiTenant.get('my_tenant_A').catch(console.error),
  }),
})

Check out the documentation and example project to learn more on how to add multi-tenancy to your Redwood apps!

Allow --schema option

If your schema isn't placed at the default location (prisma/schema.prisma), you can now use the --schema option on the Prisma-multi-tenant CLI to still be able to find it.

More documentation & small stuff

  • Blitz example app
  • Option to disable creation of example file: pmt init --no-example
  • A change on management sqlite db path resolves. It is now relative the cwd of your app. (You probably need to append with prisma/)

2.2.0

3 years ago

Today, we release the version 2.2.0! 🥳

It includes many changes, including a new architecture (multiple packages), nexus & blitz plugins, many examples, and more stuff!

New architecture

Prisma-multi-tenant has been split into multiple smaller packages:

  • @prisma-multi-tenant/shared with code used by other packages
  • @prisma-multi-tenant/client which is used by your projects to access tenants
  • prisma-multi-tenant is the CLI that you will use to manage and migrate your tenants (same as before)

Here are the steps to migrate to this new architecture in your project:

npm i -g [email protected]          # Install the new version of the CLI globally
npm uninstall prisma-multi-tenant           # Remove `prisma-multi-tenant` from your project
npm install @prisma-multi-tenant/client     # Add the client in your project

Then, in your code, change the following:

- import { MultiTenant } from "prisma-multi-tenant"
+ import { MultiTenant } from "@prisma-multi-tenant/client"

This new architecture removes the need for your project to add lot of dependencies coming from the CLI.

Nexus plugin

The Nexus Framework is a "Node.js TypeScript-focused code-first GraphQL framework", developed by Prisma.

Nexus can be coupled with Prisma to handle the data of your application, with a simple plugin:

import { use } from 'nexus'
import { prisma } from 'nexus-plugin-prisma'

use(prisma())

This release introduce a new Nexus plugin, @prisma-multi-tenant/nexus, which wraps the prisma plugin and adds multi-tenancy:

import { use } from 'nexus'
import { prismaMultiTenant } from '@prisma-multi-tenant/nexus'

const tenantRouter = (req) => {
  // The name can come from anywhere (headers, token, ...)
  return 'my_tenant_A'
}

use(prismaMultiTenant({ tenantRouter }))

Check out the documentation and example project to learn more on how to add multi-tenancy to your Nexus apps!

Blitz plugin

Blitz is a "The Fullstack React Framework", using Prisma to handle your database.

This release introduce a new Blitz plugin, @prisma-multi-tenant/blitz, which adds multi-tenancy:

const { multiTenantMiddleware } = require('@prisma-multi-tenant/blitz')

module.exports = {
  // ...
  middleware: [
    multiTenantMiddleware((req, res) => {
      // The name can come from anywhere (headers, token, ...)
      return 'my_tenant_A'
    }),
  ],
}
export default async function getProjects(args, ctx) {
  const projects = await ctx.db.project.findMany(args)

  return projects
}

Check out the documentation and example project to learn more on how to add multi-tenancy to your Blitz apps!

Documentation and examples

This release was also an opportunity to improve the onboarding of new users. To do that, nothing beats examples and tutorials!

More stuff

  • Fix issues when running cli on Windows
  • Adds pmt command as an alias to the prisma-multi-tenant command for better developer experience
  • pmt studio <name> better handles when port is already in use
  • Improves pmt init flow to handle more edge cases

2.1.0

3 years ago

Today, we release the version 2.1.0! It mainly ships the new dynamic database provider feature coming from [email protected]

New features

Dynamic database provider

You can now have tenants from multiple providers (eg. One on Mysql, the other on Postgresql). No configuration needed on your end, just run prisma-multi-tenant new and select whichever provider you want. It will just work!

Bug fixes

  • Removed false warning when running prisma-multi-tenant studio

2.0.0

3 years ago

Today is the day! 🥳

Here is the release of prisma-multi-tenant, compatible with the Prisma2 release and forward. 🎉

Compatible with @prisma/cli@^2.0.0 and after

2.0.0-beta.6

3 years ago

Note: This version is compatible with @prisma/[email protected]

Compatibility with Prisma Beta.6

Upgraded all occurences of @prisma/cli to 2.0.0-beta.6

2.0.0-beta.5

3 years ago

Note: This version is compatible with @prisma/[email protected]

Compatibility with Prisma Beta.5

Upgraded all occurences of @prisma/cli to 2.0.0-beta.5

Bugfixes

  • Fix generate bug when calling it from an npm script
  • Fix 'tenant-already-exists' message

2.0.0-beta.4

3 years ago

Note: This version is compatible with @prisma/[email protected]

Compatibility with Prisma Beta.4

Upgraded all occurences of @prisma/cli to 2.0.0-beta.4 Following the move of the generated Prisma Client to .prisma/client, the generated management prisma client was also moved to .prisma-multi-tenant/management. This should ensure more stability and less re-generations.

Features

  • The library now tries to load the prisma/.env file to access the management env variables

2.0.0-beta.3

4 years ago

Note: This version is compatible with @prisma/[email protected]

Compatibility with Prisma Beta.3

Upgraded all occurences of @prisma/cli to 2.0.0-beta.3

Bugfixes

  • Fix an issue when running init with a postgresql management db