Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
🔖 Release 2.0.0-beta.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Errorname committed May 26, 2020
1 parent a6679b2 commit ef33fa4
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ npm i -g prisma-multi-tenant@beta
```
$> prisma-multi-tenant help
🧭 prisma-multi-tenant v2.0.0-beta.5
🧭 prisma-multi-tenant v2.0.0-beta.6
USAGE
Expand Down
18 changes: 9 additions & 9 deletions docs/examples/basic-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/examples/basic-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@prisma/cli": "2.0.0-beta.5"
"@prisma/cli": "2.0.0-beta.6"
},
"dependencies": {
"@prisma/client": "2.0.0-beta.5",
"prisma-multi-tenant": "2.0.0-beta.5"
"@prisma/client": "2.0.0-beta.6",
"prisma-multi-tenant": "2.0.0-beta.6"
}
}
18 changes: 9 additions & 9 deletions docs/examples/basic-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/examples/basic-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@prisma/cli": "2.0.0-beta.5"
"@prisma/cli": "2.0.0-beta.6"
},
"dependencies": {
"@prisma/client": "2.0.0-beta.5",
"prisma-multi-tenant": "2.0.0-beta.5",
"@prisma/client": "2.0.0-beta.6",
"prisma-multi-tenant": "2.0.0-beta.6",
"ts-node": "8.6.2",
"typescript": "3.8.2"
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma-multi-tenant",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.6",
"description": "🧭 Use Prisma as a multi-tenant provider for your application",
"author": {
"name": "Thibaud Courtoison",
Expand Down Expand Up @@ -34,13 +34,13 @@
"inquirer": "^7.0.4"
},
"peerDependencies": {
"@prisma/cli": "^2.0.0-beta.5"
"@prisma/cli": "^2.0.0-beta.6"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@prisma/cli": "^2.0.0-beta.5",
"@prisma/cli": "^2.0.0-beta.6",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.1.0",
"@types/node": "^13.7.0",
Expand Down
6 changes: 2 additions & 4 deletions src/cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ class Init implements Command {
async createExample(firstTenant: Tenant | null) {
console.log('\n Creating example script...')

const { PrismaClient } = requireDistant('@prisma/client')
const { dmmf } = requireDistant('@prisma/client')

const tenant = new PrismaClient()

const firstModelMapping = tenant.dmmf.mappings[0]
const firstModelMapping = dmmf.mappings[0]

// We should use singular name (See prisma/prisma-client-js#509)
const modelNamePlural = firstModelMapping.plural
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
# Migration `20200411135513-alpha`
# Migration `20200526145455-beta`

This migration has been generated by Errorname at 4/11/2020, 1:55:13 PM.
This migration has been generated by Errorname at 5/26/2020, 2:54:55 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.

## Database Steps

```sql
PRAGMA foreign_keys=OFF;

CREATE TABLE "quaint"."Tenant" (
"id" TEXT NOT NULL ,
"name" TEXT NOT NULL ,
"provider" TEXT NOT NULL ,
"url" TEXT NOT NULL ,
PRIMARY KEY ("id")
)
"id" TEXT NOT NULL ,"name" TEXT NOT NULL ,"provider" TEXT NOT NULL ,"url" TEXT NOT NULL ,
PRIMARY KEY ("id"))

CREATE UNIQUE INDEX "quaint"."Tenant.name" ON "Tenant"("name")

PRAGMA "quaint".foreign_key_check;

PRAGMA foreign_keys=ON;
```

## Changes

```diff
diff --git schema.prisma schema.prisma
migration ..20200411135513-alpha
migration ..20200526145455-beta
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,16 @@
@@ -1,0 +1,17 @@
+datasource management {
+ provider = "sqlite"
+ url = env("PMT_MANAGEMENT_URL")
+}
+
+generator client {
+ provider = "prisma-client-js"
+ output = env("PMT_OUTPUT")
+ provider = "prisma-client-js"
+ output = env("PMT_OUTPUT")
+ binaryTargets = ["native"]
+}
+
+model Tenant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ datasource management {
}

generator client {
provider = "prisma-client-js"
output = env("PMT_OUTPUT")
provider = "prisma-client-js"
output = env("PMT_OUTPUT")
binaryTargets = ["native"]
}

model Tenant {
Expand Down
5 changes: 1 addition & 4 deletions src/cli/prisma/migrations/migrate.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY!
# INSTEAD EXECUTE `prisma migrate fix`
# Prisma Migrate lockfile v1
# Read more about conflict resolution here: TODO

20200411135513-alpha
20200526145455-beta
5 changes: 3 additions & 2 deletions src/cli/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ datasource management {
}

generator client {
provider = "prisma-client-js"
output = env("PMT_OUTPUT")
provider = "prisma-client-js"
output = env("PMT_OUTPUT")
binaryTargets = ["native"]
}

model Tenant {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const setManagementProviderInMigration = async (): Promise<void> => {
// 1. Find migration steps file
const stepsPath = path.join(
nodeModules,
'prisma-multi-tenant/build/cli/prisma/migrations/20200411135513-alpha/steps.json'
'prisma-multi-tenant/build/cli/prisma/migrations/20200526145455-beta/steps.json'
)

if (!(await fileExists(stepsPath))) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Management {
PrismaClient = requireDistant(clientManagementPath).PrismaClient
} catch {
console.error(
`\nError: Cannot find module '@prisma/prisma-multi-tenant/management'.\n\nTry running "prisma-multi-tenant generate"\n`
`\nError: Cannot find module '.prisma-multi-tenant/management'.\n\nTry running "prisma-multi-tenant generate"\n`
)
process.exit(1)
}
Expand Down
6 changes: 5 additions & 1 deletion src/shared/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ export const writeFile = (path: string, content: string): Promise<void> => {
}

export const requireDistant = (name: string): any => {
return require(require.resolve(name, {
// Keep previous env so that the required module doesn't update it
const previousEnv = { ...process.env }
const required = require(require.resolve(name, {
paths: [
process.cwd() + '/node_modules/',
process.cwd(),
...(require.main?.paths || []),
__dirname + '/../../../'
]
}))
process.env = previousEnv
return required
}

export const useYarn = (): Promise<boolean> => {
Expand Down
4 changes: 2 additions & 2 deletions tests/playground/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@prisma/client": "2.0.0-beta.5"
"@prisma/client": "2.0.0-beta.6"
},
"devDependencies": {
"@prisma/cli": "2.0.0-beta.5"
"@prisma/cli": "2.0.0-beta.6"
},
"scripts": {
"dev": "node ./script.js"
Expand Down

0 comments on commit ef33fa4

Please sign in to comment.