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

Commit

Permalink
⬆️ Use [email protected] (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Errorname authored Jan 28, 2020
1 parent 0bd7ae6 commit fea325d
Show file tree
Hide file tree
Showing 31 changed files with 2,245 additions and 3,284 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 2018,
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Thibaud Courtoison
Copyright (c) 2020 Thibaud Courtoison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,27 @@ $> prisma-multi-tenant help
Examples:
prisma-multi-tenant new
prisma-multi-tenant lift my_tenant up
prisma-multi-tenant env my_tenant -- prisma2 dev
prisma-multi-tenant migrate my_tenant up
prisma-multi-tenant env my_tenant -- prisma2 instrospect
...
COMMANDS
init Init multi-tenancy for your project
list List all tenants
new Create a new tenant
studio <name> Use Studio to access a tenant
lift <name?> <up|down> Lift up or down tenants
delete <name?> Delete one or more tenants
generate Generate Photon for the tenants and management
dev <name> Run `prisma2 dev` on a specific tenant
env <name> Set env variables for a specific tenant
help Display this help
init Init multi-tenancy for your application
list List all tenants
new Create a new tenant
studio <name> Use Studio to access a tenant
migrate <name?> <up|down> Migrate up or down tenants
delete <name> Delete one tenant
generate Generate Prisma Clients for the tenants and management
env <name> Set env variables for a specific tenant
help Display this help
OPTIONS
-h, --help Output usage information for a command
-V, --version Output the version number
--verbose Print additional logs
-h, --help Output usage information for a command
-V, --version Output the version number
--verbose Print additional logs
```

```js
Expand All @@ -104,9 +103,9 @@ Read more on how `prisma-multi-tenant` can help you achieve multi-tenancy for yo
- [Complete documentation](/docs/Complete_Documentation.md) - For curious people
- [Contributing guide](/docs/Contributing_Guide.md) - For great people
- [Examples](/examples) - For everyone
- [Basic (JS) example]()
- [Basic (TS) example]()
- [Nexus example]()
- [Basic (JS) example](/examples)
- [Basic (TS) example](/examples)
- [Nexus example](/examples)

## Author

Expand Down
60 changes: 20 additions & 40 deletions docs/Complete_Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Prisma-multi-tenant uses a "**management**" datasource in order to keep track of all the tenants of your application.

Thanks to this management datasource, prisma-multi-tenant is able to lift all your tenants, as well as providing you with a simple way to access your data of whichever tenant you want.
Thanks to this management datasource, prisma-multi-tenant is able to migrate all your tenants, as well as providing you with a simple way to access your data of whichever tenant you want.

Prisma-multi-tenant is a two-part project:

Expand All @@ -16,7 +16,7 @@ Prisma-multi-tenant is a two-part project:
- [`list`](#list)
- [`new`](#new)
- [`studio`](#studio)
- [`lift`](#lift)
- [`migrate`](#migrate)
- [`delete`](#delete)
- [`generate`](#generate)
- [`env`](#env)
Expand Down Expand Up @@ -106,7 +106,7 @@ prisma-multi-tenant new --no-management

The `new` command create a new database using your schema. It will use a name and a url (that you can provide as options).

If you want to create a tenant without tracking it in the management datasource, you can use `--no-management`. However be careful, because you will need to manually lift up and down this tenant after that.
If you want to create a tenant without tracking it in the management datasource, you can use `--no-management`. However be careful, because you will need to manually migrate up and down this tenant after that.

### `studio`

Expand Down Expand Up @@ -135,33 +135,33 @@ prisma-multi-tenant studio your_other_tenant --port=5556

The `studio` command will connect to the management datasource to retrieve the url of the tenant given as an argument. If you want to run multiple studios, you can pass a specific `--port` option.

### `lift`
### `migrate`

Lift up or down tenants.
Migrate up or down tenants.

> Note: You can also lift up the management datasource to deploy another management database: `prisma-multi-tenant lift management up`
> Note: You can also migrate up the management datasource to deploy another management database: `prisma-multi-tenant migrate management up`
**Arguments**

| Name | Optional | Description |
| ------ | -------- | ------------------------------------- |
| name | Yes | Name of the tenant you want to lift |
| action | **No** | Either lift `up` or `down` the tenant |
| Name | Optional | Description |
| ------ | -------- | ---------------------------------------- |
| name | Yes | Name of the tenant you want to migrate |
| action | **No** | Either migrate `up` or `down` the tenant |

**Examples**

```sh
prisma-multi-tenant lift your_tenant_name down
prisma-multi-tenant lift up
prisma-multi-tenant lift your_other_tenant up -- --auto-approve
prisma-mutlite-annt lift management up
prisma-multi-tenant migrate your_tenant_name down
prisma-multi-tenant migrate up
prisma-multi-tenant migrate your_other_tenant up -- --auto-approve
prisma-mutlite-annt migrate management up
```

**Explanations**

The `lift` command is a wrapper to the `prisma2 lift` command. If you pass the `name` argument, it will lift a single tenant. Otherwise, it will apply the action to all of the tenants registered in the management datasource.
The `migrate` command is a wrapper to the `prisma2 migrate` command. If you pass the `name` argument, it will migrate a single tenant. Otherwise, it will apply the action to all of the tenants registered in the management datasource.

Any arguments written after `--` will be passed to `prisma2 lift`.
Any arguments written after `--` will be passed to `prisma2 migrate`.

### `delete`

Expand All @@ -181,7 +181,7 @@ prisma-multi-tenant delete your_other_tenant

**Explainations**

The `delete` command will lift down the tenant datasource and unregister it from the management datasource.
The `delete` command will migrate down the tenant datasource and unregister it from the management datasource.

If you do not specify a tenant name as argument, it will do this for all registered tenants.

Expand All @@ -199,26 +199,6 @@ prisma-multi-tenant generate

The `generate` command generates the Photon package for both Tenants and Management.

### `dev`

Run `prisma2 dev` on a specific tenant

**Arguments**

| Name | Optional | Description |
| ---- | -------- | ------------------------------------- |
| name | **No** | Name of the tenant you want to dev on |

**Examples**

```sh
prisma-multi-tenant dev your_tenant_name
```

**Explanations**

The `dev` command is simple a wrapper of `prisma2 dev` using the tenants URL.

### `env`

Set env variables for a specific tenant
Expand All @@ -232,7 +212,7 @@ Set env variables for a specific tenant
**Examples**

```sh
prisma-multi-tenant env your_tenant_name -- prisma2 lift save
prisma-multi-tenant env your_tenant_name -- prisma2 migrate save --experimental
```

**Explanations**
Expand Down Expand Up @@ -323,7 +303,7 @@ console.log(users)

Creates a new tenant in management and returns the corresponding Photon. Any options passed as second argument will be given to the Photon constructor.

This method will lift up the new database to be up-to-date with the migrations.
This method will migrate up the new database to be up-to-date with the migrations.

> Note: You currently can't have tenants from multiple datasources. (See #8)
Expand All @@ -345,7 +325,7 @@ console.log(users)

Delete a tenant in management.

This method will lift down the database.
This method will migrate down the database.

**Usage**

Expand Down
2 changes: 2 additions & 0 deletions docs/Contributing_Guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Contributing Guide

Work in progress...

- How to clone and install pmt
- How to link it
- Gitmojis
14 changes: 7 additions & 7 deletions docs/Getting_Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ In this documentation, we will follow a step-by-step tutorial on how to add mult
- [3. Add a new tenant](#3-add-a-new-tenant)
- [4. Open Studio for a tenant](#4-open-studio-for-a-tenant)
- [5. Use the library to access your tenants](#5-use-the-library-to-access-your-tenants)
- [6. Develop on a specific tenant](#6-develop-on-a-specific-tenant)
- [6. Watch and generate Prisma Clients](#6-watch-and-generate-prisma-clients)
- [7. Deploy your schema on all tenants at once](#7-deploy-your-schema-on-all-tenants-at-once)

## 0. How does Prisma-multi-tenant works

Prisma-multi-tenant uses a "**management**" datasource in order to keep track of all the tenants of your application.

Thanks to this management datasource, prisma-multi-tenant is able to lift all your tenants, as well as providing you with a simple way to access your data.
Thanks to this management datasource, prisma-multi-tenant is able to migrate all your tenants, as well as providing you with a simple way to access your data.

Prisma-multi-tenant is a two-part project:

Expand Down Expand Up @@ -121,20 +121,20 @@ console.log(users)

You can access any tenant you want, simply by using their name!

## 6. Develop on a specific tenant
## 6. Watch and generate Prisma Clients

To develop on a specific tenant, run the following command:
To watch abd generate Prisma Clients, run the following command:

```sh
prisma-multi-tenant dev your_tenant_name
prisma-multi-tenant generate --watch
```

## 7. Deploy your schema on all tenants at once

If you want to make changes to your schema and lift all your tenants at the same time, you can do it using the following command:
If you want to make changes to your schema and migrate all your tenants at the same time, you can do it using the following command:

```sh
prisma-multi-tenant lift up
prisma-multi-tenant migrate up
```

---
Expand Down
Loading

0 comments on commit fea325d

Please sign in to comment.