Closed asaadawey closed 4 years ago
Hi 👋 Thank you for reporting this issue and sorry for taking this long to answer 🙏
It looks like you used quotes ("
) when providing the url of the management, can you try without them ?
@Errorname
No any problems sir Also when trying to initate without qutoes is stucking at "Setting up managment database"
Here is the log
D:\7SSCarRentalProject\New Code\Backend>pmt init --verbose
Installing `@prisma-multi-tenant/client` as a dependency in your app...
$> npm install @prisma-multi-tenant/client@2.3.0
npm WARN @nexus/schema@0.15.0 requires a peer of graphql@^14.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN apollo-cache-control@0.1.1 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install peer dependencies yourself.
npm WARN graphql-subscriptions@1.1.0 requires a peer of graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependenc
ies yourself.
npm WARN apollo-server-core@1.4.0 requires a peer of graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies
yourself.
npm WARN apollo-tracing@0.1.4 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install peer dependencies yourself.
npm WARN apollo-upload-server@7.1.0 requires a peer of graphql@0.13.1 - 14 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-extensions@0.0.10 requires a peer of graphql@0.10.x - 0.13.x but none is installed. You must install peer dependencies yourself.
npm WARN graphql-import@0.7.1 requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-middleware@4.0.1 requires a peer of graphql@^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-playground-middleware-lambda@1.7.12 requires a peer of aws-lambda@^0.1.2 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-subscriptions@0.5.8 requires a peer of graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yoursel
f.
npm WARN graphql-upload@8.1.0 requires a peer of graphql@0.13.1 - 14 but none is installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of @nexus/schema@^0.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of @prisma/client@2.0.0-beta.4 but none is installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of graphql@^14.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-auth@1.0.0 No description
npm WARN graphql-auth@1.0.0 No repository field.
npm WARN graphql-auth@1.0.0 No license field.
We will now configure the management database:
? Management database url: postgresql://postgres:123456@localhost:5432/postgres2?schema=public
? Are you sure of your inputs? Yes
Updating .env and schema.prisma files...
Generating prisma clients for both management and tenants...
$> node "D:\7SSCarRentalProject\New Code\Backend\node_modules\@prisma\cli\build\index.js" generate --schema prisma/schema.prisma
Environment variables loaded from provided --schema directory
┌─────────────────────────────────────────────────────────┐
│ │
│ Update available 2.5.1 -> 2.6.2 │
│ Run npm i --save-dev @prisma/cli to update │
│ │
└─────────────────────────────────────────────────────────┘
$> node "D:\7SSCarRentalProject\New Code\Backend\node_modules\@prisma\cli\build\index.js" generate
✔ Generated Prisma Client to .\..\..\..\.prisma-multi-tenant\management in 649ms
You can now start using Prisma Client in your code:
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
Explore the full API: http://pris.ly/d/client
Setting up management database...
$> node "D:\7SSCarRentalProject\New Code\Backend\node_modules\@prisma\cli\build\index.js" migrate up --create-db --experimental
Great for the quotes 👍
You are providing the following url: postgresql://postgres:123456@localhost:5432/postgres2?schema=public
. Are you using a different schema for the management database?
Prisma-multi-tenant currently uses the "one tenant = one database" model, which also requires another database for the management. (However, once #40 is implemented, you will be able to use the "one database = multiple tenants")
i haven't even initiated the pmt . i currently using one schema at postgres2 db
here is a photo
here is the .env file
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#using-environment-variables
# Prisma supports the native connection string format for PostgreSQL, MySQL and SQLite.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="postgresql://postgres:123456@localhost:5432/postgres2?schema=public"
# The following env variable is used by prisma-multi-tenant
MANAGEMENT_URL=postgresql://postgres:123456@localhost:5432/postgres2?schema=public
i have also tried now to remove the space from the directory but no chance . still stuck at Setting up managment Database
You need to provide a different schema for the management.
Example:
MANAGEMENT_URL=postgresql://postgres:123456@localhost:5432/postgres2?schema=management
Still same
cloned the public schema to managment schema as shown :-
Log
D:\7SSCarRentalProject\NewCode\Backend>pmt init --verbose
Installing `@prisma-multi-tenant/client` as a dependency in your app...
$> npm install @prisma-multi-tenant/client@2.3.0
npm WARN @nexus/schema@0.15.0 requires a peer of graphql@^14.5.0 but none is inst
alled. You must install peer dependencies yourself.
npm WARN apollo-cache-control@0.1.1 requires a peer of graphql@0.10.x - 0.13.x bu
t none is installed. You must install peer dependencies yourself.
npm WARN graphql-subscriptions@1.1.0 requires a peer of graphql@^0.10.5 || ^0.11.
3 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer d
ependencies yourself.
npm WARN apollo-server-core@1.4.0 requires a peer of graphql@^0.9.0 || ^0.10.0 ||
^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer depen
dencies yourself.
npm WARN apollo-tracing@0.1.4 requires a peer of graphql@0.10.x - 0.13.x but none
is installed. You must install peer dependencies yourself.
npm WARN apollo-upload-server@7.1.0 requires a peer of graphql@0.13.1 - 14 but no
ne is installed. You must install peer dependencies yourself.
npm WARN graphql-extensions@0.0.10 requires a peer of graphql@0.10.x - 0.13.x but
none is installed. You must install peer dependencies yourself.
npm WARN graphql-import@0.7.1 requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0
.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourse
lf.
npm WARN graphql-middleware@4.0.1 requires a peer of graphql@^0.12.0 || ^0.13.0 |
| ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-playground-middleware-lambda@1.7.12 requires a peer of aws-lambd
a@^0.1.2 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-subscriptions@0.5.8 requires a peer of graphql@^0.10.5 || ^0.11.
3 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies
yourself.
npm WARN graphql-upload@8.1.0 requires a peer of graphql@0.13.1 - 14 but none is
installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of @nexus/schema@^0.13.1 but none is
installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of @prisma/client@2.0.0-beta.4 but n
one is installed. You must install peer dependencies yourself.
npm WARN nexus-prisma@0.13.0 requires a peer of graphql@^14.5.0 but none is insta
lled. You must install peer dependencies yourself.
npm WARN graphql-auth@1.0.0 No description
npm WARN graphql-auth@1.0.0 No repository field.
npm WARN graphql-auth@1.0.0 No license field.
We will now configure the management database:
? Management database url: postgresql://postgres:123456@localhost:5432/postgres2?
schema=management
? Are you sure of your inputs? Yes
Updating .env and schema.prisma files...
Generating prisma clients for both management and tenants...
$> node "D:\7SSCarRentalProject\NewCode\Backend\node_modules\@prisma\cli\build\
index.js" generate --schema prisma/schema.prisma
Environment variables loaded from provided --schema directory
$> node "D:\7SSCarRentalProject\NewCode\Backend\node_modules\@prisma\cli\build\
index.js" generate
✔ Generated Prisma Client to .\..\..\..\.prisma-multi-tenant\management in 624ms
You can now start using Prisma Client in your code:
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
Explore the full API: http://pris.ly/d/client
Setting up management database...
$> node "D:\7SSCarRentalProject\NewCode\Backend\node_modules\@prisma\cli\build\
index.js" migrate up --create-db --experimental
You need an empty schema for the management. Prisma-multi-tenant will handle the schema itself using Prisma to create a table to handle your tenants. (Maybe I need to improve the documentation to better explain this)
Yesss
This solves the issue . one last question . how i can add tables in the managment schema ?
Awesome! 😄
Prisma-multi-tenant currently "hides" the management prisma schema, so you would need to manually add tables in the management database.
What would be your use case for this ?
@Errorname Thank you for your support really appreciated
I will tell you my questions regarding pmt and hopefully i can get answers
i have a multi tenant application with prisma
i need to use this tool to implement the multi-tenancy logic
Now i have initiated a pmt via pmt init What is the purpose of the managment database ? Is this schema will be synchronised with the other tenants ?
for example . if i have edited a foreign key in the managment schema Is all of my tenants will have the same effect ?
Alright, so here is how Prisma-multi-tenant works:
You have a management database (here the "management" postgresql schema). This management db is solely handled by Prisma-multi-tenant. It will only contain the references (name + url) to all of your tenants.
You will also have other databases (=postgresql schema): one for each of your tenant.
To create a new tenant, you simple have to call the pmt new
command, which will then ask you the desired name + url of the tenant. After that, prisma-multi-tenant will create the database (=postgresql schema) itself, and add the name+url of the tenant in the management database.
So: 1 db for management + X databases for your tenants.
When you want to migrate all of your tenant's databases at the same time, you can call pmt migrate up
which will actually call prisma migrate
on each of the tenant's databases, one by one.
I hope I was able to answer your questions 🙂
Yes this clarify it
Thank you so much this issue can be closed now
Hello , this my first time to use pmt and i cant initaite a pmt
i think there is a typo because the application trying to read from PMT_MANAGMENT_URL while the created one is MANAGMENT_URL