Scripting data schemas and seed data?

We are looking for a way to script schema migrations and seed data.

The use case:

Parse is running on a local development machine where schema changes and seed data are developed and / or modified from a previous state.

Once development changes are finished, we would like to be able to automate the process of applying these schema and seed data changes to other development and test environments and also the production environment without risk of human error and the time spent using tools like the dashboard.

We don’t want to open field and / or class creation in production, so this can’t happen dynamically through application usage.

This process is typical in a lot of application stacks like rails, dotnet, etc. Migration files that are generated or written and then run sequentially against other environments.

Am I thinking about this problem correctly? Redirect me if there’s a different way to solve this problem with parse or let’s talk about data migrations in parse.

Conceptually a tool could be written that enumerates the schema using a master key and can apply this schema to another instance of parse. Give it a list of seed tables and it could track rows for these tables as well. This gets more complicated if you want to script diffs because you can’t recreate a schema that already exists. Would need to identity existing tables and build an appropriate schema update. Does anything like this already exist?



I am pretty sure that Parse server has an API where you can read the definition of a class (ie. its field names/types). Once you have that you could compare it with the target system and write out the DIFFS between them.

Looks like this API will let you modify or create the classes but I would personally feel very uncomfortable doing so. I would rather just have the tool spit out the diffs between the two system and let me manually apply the changes into PROD. At least until the toold has been tried and tested… I would hate to delete someones production tables because of a bug… :slight_smile:

1 Like

I would also add that perhaps this “tool” should be integrated into the Parse Dashboard rather then be its own standalone tool.

@ATrcked, thanks for the response.

Yeah, this makes a lot of sense. I agree, should be built into the dashboard. Maybe I’ll look into this. Would be really nice if you could generate a list of diffs and then save them in some format that you could apply to another environment or something.

1 Like

On my side, I built a stateless script (auto migrations), that seems to correspond to your needs. (May be I’ll try to transfer this feature to parse server repo in late 2020)

I use this project to pre create/update/maintain class, schemas, indexes, Clps, and other options available on Schema Class API.

If you want an example here my repo, check the server.ts file and the onServerStartComplete function into server set up.

buildSchema.ts is the script.

Then you could probably copy and past my script to make it work in your Env.

Enjoy !

Note: My script is just a pull and diff system

1 Like

I’ll take a look, @Moumouls. Thanks!

It will be helpful to have a start point. Building this from scratch sounded like it could be a lot of work.