The best way to migrate data, files, schemas etc. is to use:
pos-cli uploads push
- to send zipped with files to our storage
pos-cli data import
- to send schema and models that will reference those files
Not only it is the fastest way, it is probably the easiest. This is what we do in our template:
Push
pos-cli uploads push <YOUR_ENV_NAME> --path=pdfs.zip
Files will land on the storage under path instances/:instance_id/property_uploads/<your path>
because .zip file will be extracted in place and kept the structure inside of it.
So you can structure directories to nest files under files/pdf/2020/
and it will respect it and extract it to instances/<instance_id>/property_uploads/files/pdf/2020/myfile.pdf
Import
pos-cli data import <YOUR_ENV_NAME> --path=data.zip --zip
You need to create schema and records in it to connect references to your files. Your schema (ie. pdfs
must include property (ie. file
) with type upload
. upload_url
of that record will be url of your file (which you already know what will be, because it it deterministic).
Each record will look more or less something like this:
id,properties,model_schema,created_at,updated_at
{"file":{"path":"files/pdf/2020/myfile.pdf","versions":{},"extension":"pdf","file_name":"file.pdf"},"label":"my pdf file from 2020" },pdfs,2021-03-31 13:17:29 UTC,2021-03-31 13:17:29 UTC
Read more on uploads here: https://documentation.platformos.com/developer-guide/user-uploads/user-uploads
You can take a look at our template repo to see how we did it (to generate seeds you need to clone the repo):
https://github.com/mdyd-dev/product-marketplace-template/tree/master/seed