Skip to content

Commit 20f94c3

Browse files
authored
feat: defined schema existing install (#915)
1 parent 5762450 commit 20f94c3

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Defined Schemas with existing installation
2+
3+
Defined Schemas is a feature in Parse Server that allows you to define the structure of your data in the database and ensure that it stays consistent. When the server starts up, it compares the current existing schemas to the Defined Schemas that you have provided, and applies any necessary changes to bring them in line with each other.
4+
5+
To use Defined Schemas on your existing Parse Server installation, follow the steps below carefully:
6+
7+
## 1. Connect to your Parse Dashboard
8+
9+
If you already have an hosted or deployed Parse Dashboard, you can skip to step 2. If not, you can follow the "Getting Started" guide for the Parse Dashboard: [Parse Dashboard Getting Started](https://github.com/parse-community/parse-dashboard#getting-started)
10+
11+
## 2. Extract Schemas using JS Console
12+
13+
To access the API Console and JS Console in the Parse Dashboard:
14+
15+
- On the Parse Dashboard, go to the left sidebar and click on "API Console".
16+
- In the API Console, click on "JS Console".
17+
- In the JS Console, copy and paste the following code:
18+
19+
```js
20+
const schemas = await Parse.Schema.all();
21+
console.log(JSON.stringify(schemas));
22+
```
23+
24+
- Click "Run".
25+
26+
After running this code, you should see a JSON string of your current schemas displayed in the console, including their CLPs (Class Level Permissions), indexes, and fields. This will give you an overview of the current structure of your data in the database.
27+
28+
## 3. Paste schemas in your existing code
29+
30+
Follow the ["Getting Started" section](/defined-schema/guide) of Defined Schema and paste your extracted JSON string. With luck your IDE, will reformat the JSON for you. Otherwise you can easily find online tools to convert JSON string to JS Array/Object.
31+
32+
## 4. Backup your database
33+
34+
As a best practice, before any deployment that involves Schema changes, perform a full database backup to prevent any data loss and to be able to roll back if something goes wrong.
35+
36+
## 5. Deploy your new Parse Server with Defined Schemas
37+
38+
Once the backup is done, you can deploy your new Parse Server. After the deployment, you can check the Parse Dashboard to ensure that all of your classes, fields, indexes, and CLPs are correct.
39+
40+
If something goes wrong during the deployment, you can roll back your database, deploy the previous version of your Parse Server, adjust and review your Defined Schemas, and then repeat steps 4 and 5.
41+
42+
## 6. Future deployments
43+
44+
If you are using Defined Schemas, it is recommended to set up a CI/CD (Continuous Integration/Continuous Deployment) process to automate your deployments. In this case, you should use the lockSchemas: true option to prevent any conflicts with create/update API calls sent to the Schema API from the Parse Dashboard or other SDKs.
45+
46+
To create or update schemas (fields, indexes, CLPs) in the future, you will need to make the necessary changes in your Parse Server code and deploy a new version of your app.

defined-schema.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ redirect_from:
1111

1212
sections:
1313
- "defined-schema/getting-started.md"
14+
- "defined-schema/how-to-use-on-existing-parse-server.md"
1415
- "defined-schema/core-classes-fields.md"
1516
- "defined-schema/fields.md"
1617
- "defined-schema/indexes.md"

0 commit comments

Comments
 (0)