Import existing data
Use an import to bring the data from your app's old database into a MultiPaaS application. An import writes everything or nothing. You need permission to manage the application's access.
Before you start, add every entity and field the old data needs to your model. See Model your data.
Prepare the files
Export your old data as JSON-lines files, with one JSON object per line. Put them all in one directory. You need these files:
tenants.jsonl, with one line per app-tenant. An app-tenant is an account, team or organization in your old app.users.jsonl, with one line per user.memberships.jsonl, with one line per user in a tenant.- One file per entity, named after the entity.
Here is one line from each. The values are made up.
tenants.jsonl:
{"id": "t-100", "name": "Acme Kitchen"}
{"id": "t-200", "appTenant": "8c1f…"}
The first line makes a new app-tenant. The second puts t-200 into an app-tenant you already have, and 8c1f… stands for that app-tenant's id. See Import into an app-tenant you already have.
users.jsonl (name is optional):
{"id": "u-7", "email": "sam@example.com", "name": "Sam"}
memberships.jsonl:
{"user": "u-7", "tenant": "t-100", "role": "Member"}
Recipe.jsonl:
{"id": "r-1", "tenant": "t-100", "createdBy": "u-7", "createdAt": "2026-01-15T10:00:00Z", "updatedAt": "2026-01-15T10:00:00Z", "deletedAt": null, "fields": {"title": "Pancakes"}}
Every id is an id from your old database, and one id names one row of its entity, across every tenant and the app-wide rows. A reference to another row uses that row's old id. MultiPaaS assigns new ids (or, for a tenant you map onto an existing app-tenant, uses that app-tenant) and keeps the references right. The role in a membership must be one your application declares.
createdAt, updatedAt and deletedAt are optional, and each may be null. A value that is present is written as YYYY-MM-DDThh:mm:ss, with optional fractional seconds, then Z or a ±hh:mm offset, such as 2026-01-15T10:00:00Z or 2026-01-15T04:00:00.5-06:00. It must fall on a date that exists, between the years 1 and 9999 in UTC. A timestamp field takes the same form.
In fields, use each field's graphqlFieldName, which multipaas model show prints. Name an entity's file after its name, its type name or its plural name. Each file can be at most 512 MiB. A list field's value is a JSON array of at most 1,000 strings, such as "tags": ["a", "b"]; on an enum list each string is one of the enum's values. A null element, a nested array, a non-string element, more than 1,000 elements or an enum value the enum lacks is refused. A one-dimensional text[], varchar[] or enum array column exports as a JSON array of strings; an integer[] exports numbers and is refused.
Files
An import carries the files that records hold. Put them in a files folder inside the directory, beside the .jsonl files, in folders if you like:
DIR/
Recipe.jsonl
files/
pancakes.jpg
pies/apple.jpg
In a line's fields, set each file field to the file's path under files, written with / separators:
{"id": "r-2", "tenant": "t-100", "fields": {"title": "Apple pie", "photo": "pies/apple.jpg"}}
multipaas import create uploads every file under files with the .jsonl files. It follows symlinks: files itself, or any file or folder under it, can be a link, and each file is named by the path it is reached at under files. A link to a folder uploads every file under it, whether or not a line names one, so check where each link points before you run import create: find -L DIR/files -exec test -h {} \; -exec ls -ld {} \; -exec realpath {} \; lists them, including links inside a linked folder, each followed by the real path it leads to. A link that points at nothing, into a chain of links that loops, or at a folder it sits inside stops import create before anything is made, and the message names the link. Point a link that points at nothing or into a loop straight at the file or folder it stands for. If that no longer exists, remove the link; import check then lists each line that named a file through it as a missing file. Remove a link to a folder it sits inside. To add one file to an import you already made, put it under files at the path your lines use, and run multipaas import add --app APP_ID --env ENV_ID --import IMPORT_ID --kind files --name PATH --file DIR/files/PATH. Keeping it under files means a new import made from the directory carries it too. A name can be at most 255 bytes. Uploading files needs CLI 1.4.0 or later, and following symlinks needs CLI 1.5.0 or later (an older CLI skips links, so import check reports the lines that name their files as missing-file); declaring a file field with the CLI needs CLI 1.1.0 or later.
import check reports a line whose file field doesn't name a file in the import, as missing-file: put the file under files at the path the line names, or correct the line, then run import create again for a new import. It reports a file that is larger than the field allows as file-too-large: shrink the file, or raise the field's limit with multipaas field update --app APP_ID --id FIELD_ID --max-file-bytes BYTES, where FIELD_ID is the file field's id from multipaas model show. A required file field needs a file in every line.
One import can name at most 11,000 files and 99 GiB of them, counting a file once for each line and field that names it. import check reports an import over either limit as too-many-files, with no file or line. To go on, split the data across several imports, and plan every import before you run the first. A row names another through tenant, createdBy, a membership's user and tenant, a reference or a parent field. Rows that can each reach the other by following names, directly or through other rows, must all share one import. Count a name that points at a record with a non-null deletedAt as pointing both ways, because a later import can't name a deleted record. For example, A names B, B names C and C names A share one import. So do a deleted record D, every row that names D, and every row on a path of names between those rows. If such a group still exceeds a limit, the data can't be split to fit: don't run any import, and report it to MultiPaaS. Each import is all-or-nothing on its own, but together they are not: an import that already ran stays written if a later one fails.
- Within one app-tenant's plan, put each tenant, user, record and membership in one import only, except the
appTenantline that an old tenant id in more than one live app-tenant needs again in every import that names it (seeambiguous-tenantbelow). Put a row in the same import as every row that names it, or in an earlier one, throughtenant,createdBy, a membership's user and tenant, a reference or a parent field. A later import that lists a row an earlier import already holds getsalready-imported: remove that line. The lines that name a tenant an earlier import put into one live app-tenant still resolve while it is live. For a tenant in more than one live app-tenant they need anappTenantline in this import (seeambiguous-tenantbelow). A record is held in the app-tenant it went into, or app-wide when it is an app-wide record, so the same source can go into a second app-tenant (see Import into an app-tenant you already have). A user is held per environment: a later import that repeatsusers.jsonllinks each user whose email is unchanged to the same account, and a user whose email changed, or whose account was deleted, getsalready-imported. A membership listed again in a later import is not reported, andimport checkreportsduplicate-membershiponly for a repeat within one import. The repeat is skipped only while the earlier invitation for that app-tenant, role and account email is neither accepted nor deleted, a lapsed one included (a repeat creates no invitation of its own, so renew a lapsed one withmultipaas import reissue --app APP_ID --env ENV_ID --import EARLIER_IMPORT_IDon the earlier import whose run made it; use--tenant APP_TENANT_IDin place of--importonly when--importcannot reach it, because--tenantre-issues every lapsed import invitation of that app-tenant, other imports' included, and so can renew a role you did not mean to: list them first withmultipaas import invitations --app APP_ID --env ENV_ID --tenant APP_TENANT_IDand check the list;import reissuerenews what is lapsed when it runs). Otherwise, including when the account's email has changed since, it creates a new invitation, which re-adds or re-invites the person at their next sign-in. - To leave out a line, remove it from this import and from every later import you planned (for a tenant's record, only those into the same app-tenant: a copy going into another app-tenant is judged there on its own), then handle every line that names it in those imports, directly or through other lines, as follows. A line that names it only through
createdBy, or through a reference or parent field that isn't required, stays with that name cleared: leavecreatedByout or writenull, and set a field tonullas thebroken-referenceproblem below describes (null, never"", andnullrather than leaving the field out, with the same note on the parent field of an unmanaged entity). A line that names it throughtenant, a membership's user or tenant, or a required reference or parent field is removed, and the lines that name it are handled the same way, by how each names it, at every depth. Tell whoever owns the data which lines you cleared and which you removed. This does not apply to a line you remove because an earlier import already holds its row: the lines that name it resolve to what that import made while it is live, so keep them. The exceptions are a tenant in more than one live app-tenant, whose lines need anappTenantline in this import (seeambiguous-tenantbelow), and a user or record that has since been deleted (see theunknown-userandbroken-referenceproblems below). - If any import of a split fails, the first included, because a row it names is in a file of an import you planned but haven't run (
unknown-userorunknown-tenantfor a user or tenant,broken-referencefor a record), the plan was wrong. Plan again every import you haven't run, this one included, under the rules above, and runimport createfor the first of them. unknown-userorunknown-tenantmeans no live user or tenant with that id is in this import or in an import that already ran. If an import that already ran holds it, it has been deleted since. Listing the user again getsalready-imported. Listing the tenant again withnamemakes a new app-tenant for its old id, and withappTenantmaps it onto an app-tenant you already have (one an earlier import holds under another old id isduplicate-app-tenant, see below); its lines go into that one. Decide with whoever owns the data: drop a record'screatedBy, so that whoever runs the import creates the record, leave out a membership, or, for a tenant, leave out every line that names it, or list it again, withnameorappTenant. Listing it again, withnameorappTenant, gives the app-tenant none of the deleted one's records or members. Putting every earlier record line back as in the source restores each one: a record deleted in MultiPaaS since the earlier import comes back live in the app-tenant its line goes into (the new one withname, the one the tenant is mapped onto withappTenant), one edited since returns to its source values, and the deleted app-tenant stays deleted. Check that this is what you want before you list it again. Put every earlier record line of that tenant, as in the source, with its original id, in any one import of the plan (no later than the first whose lines name it, if any), with every row it names in that import or an earlier one. A line with a non-nulldeletedAtgoes in the same import as every line that names it, as the split rule says. Put the membership lines of the people who should be in it in this import or a later one, as the second-app-tenant steps in Import into an app-tenant you already have describe; otherwise references to the records arebroken-referenceand the tenant has no members. If it is in none of your files, decide with them whether to supply the row in this import's replacement, drop thecreatedBy, or leave out the line.- In a later import,
broken-referencefor a record an import that already ran holds depends on that record's line in the import's file. A line can name a record of its own tenant or an app-wide record, and an app-wide line can name only app-wide records. If the record is in the line's own old tenant but an earlier import put it only into a different app-tenant (the same source going into a second app-tenant, with its line left out of this import), the reference isn't wrong: add that record's line, with its original id, to this import. Otherwise, if the record is one the line can name, it has been deleted, whether its line has a non-nulldeletedAtor it was deleted since. A later import can't name a deleted record. When the line's reference field isn't required, tell whoever owns the data, then set the field tonull, never""(broken-reference): the line and the lines that name it stay. Writenullrather than leaving the field out, because a field with a default that is left out gets the default record. If the field is the parent field of an unmanaged entity, the record and the records under it can then be read only by roles that read every record of their entity or of one above it. When the field is required,nullismissing-field: tell whoever owns the data, then leave out the line. Don't list the record again: it getsalready-imported. If the record is one the line can't name (it is in another tenant, or it is a tenant's record and the line is app-wide), the reference is wrong: fix it. - Keep a line in the same import as its parent, the records it references and, for an entity with a unique constraint, the tenant it goes in, wherever you can. A later import needs more access than one import would: read access to the entity's records for each earlier record a line references or has as its parent, and read access to an entity with a unique constraint in each existing app-tenant a line goes into (one an earlier import made or mapped onto, or this import maps onto), or app-wide for an app-wide line. Without it
import checkreportscheck-unauthorized. A line whose parent is in an earlier import also needs edit access to that parent when the import runs, or the run fails withimport-unauthorized, after the check has passed. - Give each import only the files its lines name, under its own
filesfolder. - Check and run each import before you make the next. A later import resolves an earlier one's rows only after the earlier one has run.
- If an import fails, handle it by its status and problem code, as the sections below describe, and don't run the next import until it has imported. Fixing a data or model problem means making a new import. For
check-unauthorizedandimport-unauthorized, get the access named in the message from someone who can grant it, then check the same import again, as the sections below describe. Animport-errorwhose message doesn't end "Try again" is not retried.
import run puts a copy of the file on each new record that names it, so two lines that name one file each get their own copy. The record's file is read with the same access as the record, through the generated API.
App-wide records
An app-wide record belongs to no app-tenant, and every app-tenant in its environment shares it. See Applications and app-tenants. To import one, set its tenant to null.
Word.jsonl:
{"id": "w-1", "tenant": null, "fields": {"text": "hola"}}
A line with no tenant is refused. It doesn't become app-wide. One file can hold app-wide and tenant records together.
- An app-wide record can reference only app-wide records, from this import or an earlier one. A tenant record can reference its own tenant's records and app-wide records. An app-wide record can be the parent of a tenant record only when that record's entity is managed. When a tenant record's entity isn't managed and its parent field names an app-wide record, from this import or an earlier one, the check reports
app-wide-parenton that line. Make the entity managed, or give the record a parent from its own tenant. - An app-wide record's values must not repeat another live app-wide line's in this import, or any live app-wide record's of that entity in the environment, however it was created, for any one unique constraint of its entity. A line with a non-null
deletedAtis left out both ways: its values are not checked, and other lines may repeat them. - To import app-wide records, you need
record.app_wide.createon the entity. When any of them has a non-nulldeletedAt, you also needrecord.app_wide.manage, orrecord.app_wide.editwhen the entity isn't managed. - Checking an app-wide line that has a value in every field of one of its entity's unique constraints, and no
deletedAt, needs permission to view that entity's app-wide records. A line that refers to an earlier import's app-wide record needs permission to view the referenced entity's app-wide records.
On a managed entity, each imported record that belongs to an app-tenant is managed by the user its row names, or by whoever runs the import when the row names no one, so other members don't see it unless a role gives them record.view_all or the record is shared with them: its manager can share it from the record's Sharing tab, or the entity can share its new records with the app-tenant. App-wide records aren't shared this way; roles read them with record.app_wide.view. To let everyone in each app-tenant read the app-tenant records, turn on sharing new records with the app-tenant for the entity before you run the import. If you already ran it, share the imported records with shareRecords from a job whose role holds record.manage_all for the entity. The imported records have new ids, not your old ones: list the entity's records with the job's token and scope: TENANT, which a role holding record.manage_all for the entity can read in full, and pass the ids the list returns. A list returns one page, so read every page before you share, then share the ids from all pages in batches of 100. Without scope: TENANT the list also returns the entity's app-wide records that the job's roles let it view, and an app-wide id is refused with RECORD_NOT_SHAREABLE, and the whole call with it. The list holds every live record of the entity in the app-tenant, imported or not, so sharing its ids shares the other records too. A call sets the named principal's share on each record it shares through to the level you give, and lowers a higher share that principal already holds: an everyone share at EDIT on an older record drops to VIEW if you share at VIEW. Only lowering a MANAGE share is guarded, and a call that would leave a record with no MANAGE share is refused with LAST_MANAGER. The generated API can't list shares, so narrow the list with where to the records you mean to share, share at the level you want every one of them to have, and check the Sharing tab of any record that may already be shared. A list shows live records only, so a record with a deletedAt is left out of it; don't pass a deleted record's id, because it is refused with NOT_FOUND, and the whole call with it. The job's token is for one app-tenant, and every id in a call must belong to it: an id from another app-tenant is refused with NOT_FOUND, and the whole call with it. Get a token for each app-tenant and share its records with that token. The job needs record.manage_all for the entity at each of those app-tenants, from a role it holds there or an application-wide role. An app-wide token is refused with UNAUTHORIZED.
Import into an app-tenant you already have
By default each line in tenants.jsonl makes a new app-tenant. To bring an old tenant's data into an app-tenant that already exists, do three things.
Find the app-tenant, or create it first.
ENV_IDis the environment you run the import in.multipaas tenants list --app APP_ID --env ENV_ID multipaas tenants create --app APP_ID --env ENV_ID --name "Acme Kitchen" --jsontenants create --jsonprints{"appTenant": {"id": "…", "name": "…"}}. Take theid.In
tenants.jsonl, write the old tenant's line withappTenantin place ofname:{"id": "t-200", "appTenant": "APP_TENANT_ID"}. No new app-tenant is made. Every record and membership that namest-200goes into that app-tenant, and so does a later import that names it without a tenants line for it, while that app-tenant is live and until an earlier import has put the same old id into a second live app-tenant (seeambiguous-tenantbelow).Upload, check and run the import as usual.
If you point your app at an app-tenant for deploy settings, app identities or testAppTenantId in multipaas.json, do it before you run the import, so nothing needs repointing afterwards.
A record's old id is unique per app-tenant, and an app-wide record's old id is unique app-wide. A user is held per environment and linked again when its email is unchanged. So you can import one old tenant's data into a second app-tenant with its original ids. Use the app-tenant you already have for it, as the steps above say, or create one, then make an import with:
- one
tenants.jsonlline for the tenant being imported,{"id": "OLD_TENANT_ID", "appTenant": "SECOND_APP_TENANT_ID"}, and no line for any other old tenant; - the record and membership lines of that tenant only, including the app-wide records those lines name, directly or through other app-wide lines, that no earlier import holds (otherwise
broken-reference), but leaving out the record lines an earlier import already put into that app-tenant and the app-wide records any earlier import already imported (they arealready-imported; lines naming a record left out still resolve while it is live, and a deleted one isbroken-reference, see that problem above), and each membership line an earlier import into that app-tenant already held (its files list them), unless the user asks to grant it again (a repeat can re-add the person, as the repeated-membership rule in the bullet above that begins "Within one app-tenant's plan" says, which also says how to renew a lapsed earlier invitation); - the users it needs, listed as before: a user whose email is unchanged is linked to the same account. A user whose email changed gets
already-imported: leave it out, and the lines that name it still resolve to the account it was linked to. A user whose account was deleted getsalready-importedtoo, and leaving it out makes every membership line andcreatedBythat names itunknown-user: drop that user's membership lines, and drop thecreatedBy(leave it out or writenull), so whoever runs the import creates the record.
A line in it names records of its own app-tenant first, then app-wide records, and never another app-tenant's.
Five problems can come up:
unknown-app-tenantmeans theappTenantis not a live app-tenant of this application in the import's environment. Check the id withmultipaas tenants list --app APP_ID --env ENV_ID, fix the line, and runimport createagain.invalid-valuemeans a line has bothnameandappTenant. Keep one:namefor a new app-tenant, orappTenantfor one that already exists.already-importedon a line withnamemeans an earlier import already created or mapped that old tenant id onto a live app-tenant. Leave its line out oftenants.jsonl, or, to put this import's lines into another app-tenant, write anappTenantline in its place. When earlier imports put it into one live app-tenant, lines in this import that name it still find it, as long as that app-tenant is live. For one that has been deleted since, see theunknown-userorunknown-tenantproblem above. When they put it into more than one live app-tenant, leaving the line out makes every line that names itambiguous-tenant: write theappTenantline instead. A line withappTenantnever getsalready-imported: onto the app-tenant an earlier import already mapped that old id to, or made from it, it selects that app-tenant and records nothing new.ambiguous-tenantmeans a line names an old tenant id that earlier imports put into more than one live app-tenant, and this import'stenants.jsonlhas no line for it. A line withnamefor it isalready-imported, so only anappTenantline fixes it. Add{"id": "OLD_TENANT_ID", "appTenant": "APP_TENANT_ID"}for the app-tenant this import is for, then runimport createagain.duplicate-app-tenantmeans theappTenantis already held by an earlier line of this import, or by an earlier import (created or mapped) under a different old id. An app-tenant takes one old id. Delete the refused line and change every record and membership row that names its old id to name the other old id. The other old id is the earlier line's, which keeps its line, or the earlier import's, which needs no line in this import unless that old id is in more than one live app-tenant. Then add{"id": "EARLIER_OLD_ID", "appTenant": "APP_TENANT_ID"}naming the app-tenant that holds it, as theambiguous-tenantproblem above says. Leave out a membership row the earlier import already gave unless you mean to grant it again (see the repeated-membership rule in the bullet above that begins "Within one app-tenant's plan", which also says how to renew a lapsed earlier invitation). Either way, this puts both old tenants' data in one app-tenant. Delete any membership row that the change makes a repeat of another, because a user who had the same role in both would otherwise getduplicate-membership. Then runimport createagain. If the new import's check then reportsduplicate-unique-key, records share a unique constraint's values: two lines of this import, or a line and a record already in the app-tenant (one an earlier import made, or one no import made). Decide which record to keep, then take one of these:Keep both. Change one line's unique-constraint values so it no longer clashes.
Keep the other record and drop this line. First change every reference field that points at this line's entity and names its old id, in every line that resolves to this record, so it names the other record's old id. A reference resolves in its line's own app-tenant first, then app-wide, as the sentence that begins "A line in it names records of its own app-tenant first" says: for a tenant record that is the lines of its app-tenant, and for an app-wide record the app-wide lines and the tenant lines whose own app-tenant has no record of that entity with that old id. Otherwise those lines get
broken-reference. A field that points at another entity and holds the same string names a different record: leave it. This works when the other record has an old id: a line of this import, or an earlier import's record, which is named by its old id while it is live. To merge instead of dropping, copy the values you want onto the other record: into its line when it is a line of this import, or withmultipaas records update --app APP_ID --tenant APP_TENANT_ID --entity ENTITY_ID --id RECORD_ID --data 'JSON'(--datais keyed by field id, frommultipaas model show, not by the names the import lines use) when it is already in the app-tenant. Throughrecords updatea reference value is the referenced record's MultiPaaS id, not an old id; when that record comes from this import, set it after the import runs. That update is made outside the import, so it stays even if the import's check fails or it is not run.Keep this line over a record already in the app-tenant. This applies whether an earlier import made that record or no import did. The line is imported as a new record and the old record stays until you delete it, so nothing that names it breaks on the way. Follow Replace a record with an imported line: it frees the unique values, imports the line, gives the new record the old record's shares (with the exceptions it names), then moves references and deletes the old record.
Drop this line when the other record was made by no import. That record has no old id, so no line can name it. Instead, clear the reference fields that point at this line in the other lines. Set each to
null, never""(broken-reference). You can also leave a field out offieldswhen it has no default; a field with a default that is left out gets the default record. After the import, set those references through the API. A required reference can't be cleared (missing-field): for one, keep both records or keep this line. A parent field of an unmanaged entity can be cleared, but then the record and the records under it can be read only by roles that read every record of their entity or of one above it. To merge into that record instead, copy the values you want onto it withrecords updateas above, then clear the references as here.
Then, except in the keep-this-line option, which makes its import as Replace a record with an imported line describes, make a new import with the edited files (
import create).
Replace a record with an imported line
When import check reports duplicate-unique-key between a line and a record already in the line's app-tenant, you can keep the line and have its record take the old record's place. The old record may be one an earlier import made, or one no import made. The changes you make here, with entity update, records update, records delete or on a record's Sharing tab, are made outside the import. They stay even if the import's check fails or it is not run: handle the reported problem as Upload and check or Run it says.
On a managed entity, the steps below keep the new record from letting anyone do more than the old record lets them, except in the cases listed just before step 1. People reach a record in two ways:
- Roles (
record.view_all,record.edit_all,record.manage_all), which are the same for both records. - The record's shares. Each share names a user, a group or Everyone in the app-tenant, at view, edit or manage. The record's managers are its shares at manage.
The import gives the new record these shares and no others:
- manage for the user the line's
createdBynames, or for whoever runs the import when it names no one. This section calls that user the import's manager; - when the entity shares its new records with the app-tenant, Everyone at that level.
A record of an unmanaged entity has no shares of its own. People reach it through roles and its managed parent's shares, so give the line the old record's parent and skip steps 1, 3, 4 and 6. When no import made that parent, no line can name it. Set the line's parent field to null, which leaves the new record readable only by roles that read every record of its entity, and after the import set the parent with records update, as step 8 does for references. A required parent field can't be null (missing-field), so for one, keep the other record instead. An app-wide record has no shares either, and roles alone reach it, so skip those steps for it too. Who can read which records explains roles and shares.
On a managed entity, step 6 gives the new record the old record's shares and brings the import's manager's share down to theirs on the old record. The new record can still let someone do more than the old record in these cases:
- Everyone, from the import until step 6, when the entity shares its new records wider than the old record's Everyone share and its sharing is still on when the import runs (steps 4 and 5).
- The import's manager, from the import until step 6, when the old record doesn't let them manage it: no user manages the old record (step 3), or they lose the group membership or role that let them manage it before step 6 runs.
- Anyone whose share on the old record is narrowed or removed after step 1, from that change until step 6 copies the old record's shares, or, when the change comes after step 6, until it is made on the new record too.
- The import's manager, after step 6, when the old record has no share at manage that step 6 can give the new record: to Everyone, or to a user or group its tab names. A record keeps at least one share at manage, so their share stays. They keep managing the new record, and the records step 8 moves under it, even if they lose the
record.manage_allrole that lets them manage the old one, or when they never managed it.
Shares the old record's tab shows as "Removed user" or "Removed group" aren't carried over, since those principals are no longer in the app-tenant. That only narrows access.
Note the old record's access. Open the old record's Sharing tab in the web app and note each share's principal and level. Then run
multipaas model show --app APP_ID. An entity that shares its new records with the app-tenant showsshares new records: vieworshares new records: editaftermanaged true.Free the unique values. Change the old record's unique-constraint values so it no longer clashes:
multipaas records update --app APP_ID --tenant APP_TENANT_ID --entity ENTITY_ID --id RECORD_ID --data 'JSON'--datais keyed by field id, frommultipaas model show, not by the names the import lines use. For an app-wide old record, use--app-wide --env ENV_IDin place of--tenant, whereENV_IDis the environment the import uses. The same goes for every--app-widecommand below.Name a manager the old record already has. Set the line's
createdByto the old id of a user who already manages the old record. Best is a user its Sharing tab lists at manage by name: the share the import gives them on the new record is then the same as theirs on the old one. Otherwise name a member of a group it lists at manage, any member of the app-tenant when it lists Everyone at manage, or a user whose role holdsrecord.manage_allfor the entity, as the default App manager role does. The tab names a user by their name, or by their email when their account has no name: match it to a row inusers.jsonl, or ask the user for their email. If no import made that user, add their row tousers.jsonlwith their account's email, which links it to that account. That user also becomes the new record's creator.Sometimes no user manages the old record: its shares at manage are all to groups with no members or shown as "Removed", and no one's role holds
record.manage_allfor the entity (the default App manager role does, so this needs no one with that role either). In that case, ask whoever owns the data who should manage the new record and name them, or leavecreatedByout so that whoever runs the import does.Before you go on, tell whoever owns the data which of the cases listed before step 1 apply to the import's manager.
Decide whether to keep the import from sharing the new record wider. This step applies when the entity shares its new records at a level the old record's Everyone share doesn't reach: the old record has no Everyone share, or it has one at view while the entity shares at edit. The import then gives the new record a wider Everyone share, the first case listed before step 1. To avoid that, you can turn the entity's sharing off for the moment the import runs, in step 5. That needs CLI 1.7.0 or later and a role that holds
model.edit.This changes the entity for the whole application. While sharing is off, no record of it is shared with Everyone when it is created, in any app-tenant or environment, whether a member, an app identity or an import creates it. Those records stay unshared after you turn sharing back on. Choose it only if that is acceptable.
Import the line. Make the new import with the line as it is and check it. Until the check passes, handle each problem it reports as Upload and check says: a fix to your files or model needs a new import, which you check in turn, and some problems need this import checked again. When you are back here to run the same import again, don't make a new one: check that import again where the section that sent you here says to, and run it as it is when its status is
checked. A run lasts from step 4 to the end of this step, and each time you start again at step 4 a new one begins: what you wrote down for an earlier run, for this import or another, doesn't count for this one. If you chose in step 4 to turn sharing off, first ask anyone else whose role holdsmodel.editnot to change the entity's sharing until the import has finished and any turn-off below has been undone. Then runmultipaas model show --app APP_IDand note the level the entity's line shows aftershares new records. Write it down where you'll find it again. If the line shows no level, sharing is already off: skip the turn-off. Otherwise turn sharing off right before the run:multipaas entity update --app APP_ID --id ENTITY_ID --share-with-tenant offWhatever that command prints, run
multipaas model show --app APP_IDand read the entity's line. If it still showsshares new records, sharing is on. The command needsmodel.edit: someone whose role holds it can turn sharing off for you, or you can run with sharing on. If sharing was turned off and the import then doesn't run, because you decide not to or something stops you first, have it turned back on at the level you noted before you stop, whoever turned it off, as the paragraph that begins "If you noted a level" says.Right before the run, whether or not you chose in step 4 to turn sharing off, run
multipaas model show --app APP_ID, read the entity's line, and write down the level it shows aftershares new records, or that it shows none, and the import's ID. If it showsshares new recordsat a level the old record's Everyone share doesn't reach, the first case listed before step 1 applies. Then run the import.import runcan return before the import has finished: it stops waiting after 20 minutes and tells you to runimport statuslater. Readmultipaas import status --app APP_ID --env ENV_ID --import IMPORT_ID --jsonuntil itsstatusis neithercheckingnorimporting.importedmeans the line was imported, and any other status means it wasn't. If it still showscheckingorimportingmore than 20 minutes after itsstartedAt, the import may be stuck: runmultipaas import check --app APP_ID --env ENV_ID --import IMPORT_ID, which stops a stuck import and checks it again, and keep reading the status. Ifimport statusis refused, the import's status is unknown: don't take the line as not imported, don't run the import again, and don't go on to step 6. Give the import's ID to someone who can read its status, and ask them to read it until it is neithercheckingnorimportingand tell you what it shows. If it still showscheckingorimportingmore than 20 minutes after itsstartedAt, they, or someone who can, runmultipaas import check --app APP_ID --env ENV_ID --import IMPORT_IDand keep reading it. If sharing was turned off, runmodel showand read the entity's line too. If it shows noshares new records, sharing stays off for the whole application until that status comes back and you turn it back on. Ifmodel showfails, take it that sharing may still be off, and keep the level you noted for when the status comes back. Once you have the final status, use it as the import's status from here on. Then runmodel showagain: if the entity's line showsshares new records, or you wrote down for this run that sharing is back on, leave sharing as it is; otherwise turn sharing back on as the paragraph that begins "If you noted a level" says. Then go on as the paragraph that begins "Whether or not sharing had to go back on" says.If you're interrupted after turning sharing off, for example because your terminal closed, don't start again at step 4. Come back to this step with what you wrote down. If you wrote down no import ID for this run, you hadn't run the import: don't run anything, have sharing turned back on as for an import that doesn't run, earlier in this step, then start again at step 4. If you did, read
multipaas import statusfor that ID:checkedmeans you hadn't run it, and any other status means you had. If that command is refused, don't run anything, and do what the paragraph above says for a refusedimport status. If its status waschecked, you hadn't run it: have sharing turned back on as for an import that doesn't run, earlier in this step, then start again at step 4 with that import. If you had, keep reading its status, or get it from someone who can read it as above if reading it is refused, until it is neithercheckingnorimporting, then runmodel showagain. If the entity's line showsshares new records, or you wrote down for this run that sharing is back on, leave sharing as it is and skip the next paragraph. Otherwise, use what you wrote down right before the run as whatmodel showshowed then, and turn sharing back on as the next paragraph says.If you noted a level right before turning sharing off, you haven't written down for this run that sharing is back on, and either the import doesn't run or
model showshowed sharing off right before the run, sharing has to go back on, whoever turned it off. First runmodel showagain. If it fails, ask someone whose role holdsmodel.editto run it and read the entity's line for you, and don't turn sharing back on until someone has. If the entity's line showsshares new records, someone has set sharing since, so leave it as it is, write down that sharing is back on for this run, and skip the rest of this paragraph. Otherwise someone whose role holdsmodel.editturns it back on at the level you noted:--share-with-tenant viewor--share-with-tenant edit. Check thatmodel showshowsshares new recordsat that level again, and once it does, write down that sharing is back on for this run. Until it does, the entity's sharing for the whole application isn't what it was before you turned it off: every record of the entity created in the meantime, in any app-tenant or environment, keeps the Everyone share it was created with, or none while sharing is off. So if turning it back on is refused or fails, or the check doesn't showshares new recordsat that level, have someone whose role holdsmodel.editset it to that level before you go on.Whether or not sharing had to go back on, if the line was imported, go on to step 6. If it wasn't, do what Run it says for
import-failed, or, when a stuck import's second check ended incheck-failed, what Upload and check says for that. Acheckedstatus means that check passed but the line hasn't run yet, so run it again. Some problems need a new import, some need this import checked and run again, and some mean you shouldn't retry. Whenever you run an import again, start again at step 4.Give the new record the old record's access. Right after the import runs, the new record's manager opens its Sharing tab and the old record's in the web app, and does the following, in order. Match the old record's tab as it shows now, not the notes from step 1: its shares may have changed since. If someone changes the old record's shares before step 9, make the same change on the new record.
- Makes its Everyone share match the old record's. Remove it when the old record has none. Share with Everyone at the old record's level when the levels differ: sharing again with the same principal changes that share's level.
- Shares it with each of the old record's other principals except the import's manager, at the same levels. Skip any share the tab shows as "Removed user" or "Removed group": that principal is no longer in the app-tenant and can't be shared with again.
- Makes the import's manager's share match theirs on the old record. If the old record's tab lists them by name, share with them again at that level. If it doesn't list them, remove their share. Skip this when it lists them at manage. Do this last: a record keeps at least one share at manage, so this is refused until sub-step 1 or 2 has given the new record another one.
The new record now has the old record's shares, except as the cases listed before step 1 and the paragraph after them say. To keep both records, stop here.
Wait for the rest of your imports. If you planned more imports after this one, wait until the last of them has run before going on. Until then, their lines that name the old record still resolve to it. When a later import replaces this new record in turn, finish steps 7 to 9 for this record before starting them for that one.
Move the references. Find the new record's MultiPaaS id with
multipaas records list --app APP_ID --tenant APP_TENANT_ID --entity ENTITY_ID, or with--app-wide --env ENV_IDin place of--tenantwhen it is app-wide. Then change each record that references the old one, including records these imports made, to name that id:multipaas records update --app APP_ID --tenant APP_TENANT_ID --entity REFERENCING_ENTITY_ID --id REFERENCING_RECORD_ID --data 'JSON'REFERENCING_ENTITY_IDandREFERENCING_RECORD_IDare the entity and id of the record you are changing, which may be of another entity than the new record. Run it with--tenantset to the app-tenant of the record you are changing, or with--app-wide --env ENV_IDin place of--tenantwhen that record is itself app-wide. An app-wide record can be referenced from app-wide records and from records in several app-tenants, so update each of them in its own app-tenant, or app-wide.A record of an unmanaged entity whose parent field you move this way is reached from then on through the same shares as the new record. On a managed entity, those are the new record's shares after step 6, so the cases listed before step 1 apply to the moved record too. When the new record is itself of an unmanaged entity, it has no shares of its own, so the moved record is reached through the same managed record as the new one.
Delete the old record. Deleting is destructive. Use CLI 1.9.0 or later; on an older CLI, use
records retire.multipaas records delete --app APP_ID --tenant APP_TENANT_ID --entity ENTITY_ID --id RECORD_IDFor an app-wide old record, use
--app-wide --env ENV_IDin place of--tenant, inrecords retiretoo.Any import you make after this names the new record by this line's old id, not the old record's.
For example, take a managed Project entity with a unique constraint on code, which shares its new records at edit. Your app-tenant has a project with code APL that no import made. Its Sharing tab lists Sam at manage, Everyone at view and the Finance group at edit. import check reports duplicate-unique-key for this line in Project.jsonl:
{"id": "p-41", "tenant": "t-200", "createdBy": "u-7", "fields": {"code": "APL", "name": "Apollo"}}
model showlistsProject (Project, managed true, shares new records: edit).- Change the old project's
codetoAPL-oldwithrecords update. u-7is Sam's row inusers.jsonl({"id": "u-7", "email": "sam@example.com", "name": "Sam"}), so the new project's manager and creator is Sam, who already manages the old one.- The entity shares at edit and the old project's Everyone share is view. The owner agrees to turn sharing off for the run.
- Check the import. Once the check passes, turn sharing off with
--share-with-tenant off, run the import, then turn sharing back on with--share-with-tenant edit. - On the new project's Sharing tab, Sam shares it with Everyone at view and with Finance at edit. Sam already manages the old project, so there is nothing to lower.
- This is the last import, so there is nothing to wait for.
- Move each record that references the old project to the new project's id.
- Delete the old project.
Upload and check
Upload the directory. DIR is the directory that holds your files.
multipaas import create --app APP_ID --env ENV_ID --dir DIR
APP_ID is the id that multipaas apps create or multipaas apps list printed. The command prints the import and its id. Use it as IMPORT_ID below.
An account's plan can limit the bytes its imports take in each month, counted in UTC. Each file counts its size when import create or import add adds it to an import, whether or not the import ever runs. Taking it off the import, or deleting the import, doesn't give the bytes back, so running import create again for a new import counts its files again. A file that would take the month past the limit is refused with LIMIT_REACHED and the message "This file would take this account past its monthly import limit. It resets at …", and isn't added. import create stops there; the files it added before it stay on the import and count. The limit resets at the start of next month in UTC, and a higher limit comes from a larger plan. The account's Usage page in the console shows this month's imports against the limit.
An import belongs to one environment: the --env ENV_ID you pass, else environmentId in multipaas.json when that file is for the same application (CLI 1.2.0 or later), else the default environment. Pass --env ENV_ID explicitly on import create and on every later command for this import, because each one finds imports only in its own environment. If you give none to import create, pass the environment it picked, so that changing multipaas.json later can't move the follow-ups. A replacement import, made by running import create again after a failed check or run, takes the same --env as the import it replaces, or it can land in a different environment.
Check every row:
multipaas import check --app APP_ID --env ENV_ID --import IMPORT_ID
Read the counts it prints. The import's status is checked when no row has a problem.
If the status is check-failed, nothing was written. Read each problem. Most name a file, and usually a line. Fix your files or your model, then run import create again. That makes a new import with a new id, holding only what is in the directory, so keep every file your lines name under files, including any you added with import add.
A line with no deletedAt must not repeat the values of another such line for the same app-tenant, or of a live record in that app-tenant, for any one unique constraint of its entity. Lines for different app-tenants may share values, and app-wide lines are checked among themselves, as App-wide records says. A line with a non-null deletedAt is not checked, and other lines may repeat its values. import check reports that as duplicate-unique-key, naming the fields of the constraint the line repeats, and a line can get one per constraint.
Some problems name no file. For too-many-files, split the data across several imports, as Files describes. Run import check again on the same import for check-error and check-timed-out. For check-unauthorized, you can no longer manage the application, or you lack read access to an entity's records that the check reads. It reads the records a line references or has as its parent from an earlier import, and, for an entity with a unique constraint, the records already in the tenant or app-wide scope the line goes in. Don't retry until someone who can grant the access the message names has granted it; then run import check again on the same import.
Run it
Run the import only when its status is checked:
multipaas import run --app APP_ID --env ENV_ID --import IMPORT_ID
It writes all of your data or none of it. If the status is import-failed, nothing was written. A problem other than import-error that names a file means the data or the model is wrong: fix your files or your model, then run import create again for a new import, as after a failed check. import run also reports duplicate-unique-key when another write took a line's values after the check. For import-timed-out, and for an import-error whose message ends "Try again", with or without a file, run import check and then import run again on the same import. Any other import-error, with or without a file, means MultiPaaS could not write rows that passed the check: don't change the data and don't retry, and report it to MultiPaaS with the import's id. For import-unauthorized, you can no longer manage the application, you lack read access to an entity's records that the run reads again (the ones check-unauthorized lists above), you lack permission to create or delete the records it writes, or you can't edit a record from an earlier import that a new record names as its parent. Don't retry until someone who can grant the access the message names has granted it; then run import check and import run again on the same import. For application-inactive, don't retry: the application was deleted, and a deleted application accepts no import, so load the data into an application that isn't deleted.
Imported users are not emailed. They join their tenants when they next sign in, if that is within 7 days of the run. After that, an unclaimed membership lapses.
To see how many are pending, accepted and lapsed, run multipaas import status --app APP_ID --env ENV_ID --import IMPORT_ID. multipaas import invitations --app APP_ID --env ENV_ID --import IMPORT_ID lists the lapsed ones. multipaas import reissue --app APP_ID --env ENV_ID --import IMPORT_ID gives every membership it re-issues another 7 days from now, claimed when the person next signs in, and sends no email. With --import, a membership whose tenant or role is deleted, or whose role you do not hold, is skipped and stays lapsed. For a deleted import, which import reissue --import refuses as not found, and for imports run before imports recorded their invitations, name the tenant with --tenant APP_TENANT_ID instead of --import. With --tenant alone, import reissue re-issues the lapsed memberships of every import into that app-tenant, other imports' included, which can renew a role you did not mean to, so run import invitations with the same --tenant first and check the list (EMAIL, TENANT, ROLE and EXPIRED; with --json, each invitation's dataImport is the import that made it, and null when the invitation names no import, as for imports run before imports recorded their invitations) before you re-issue, since it renews what is lapsed when it runs. Prefer --import where it reaches them. With --tenant, import reissue refuses a tenant that is deleted, unknown or outside the environment as not found, and skips a membership whose role is deleted or not held. To restore a skipped membership, invite the person again to a live tenant and role when its tenant or role was deleted, or ask someone who can manage the application's access and holds its role across the application, both in the import's environment, to run import reissue. import invitations, import reissue and the counts in import status need CLI 1.5.0 or later.
More
multipaas import --helplists every import command and its flags.- To see what an import holds, or the problems it found, run
multipaas import status --app APP_ID --env ENV_ID --import IMPORT_ID. - The platform API has the same: the
invitationsquery takes awherefilter (appTenantId,dataImportId,kindandstatus), and thereissueImportInvitationsmutation re-issues the lapsed invitations of an import or a tenant. - Read the model for how entities and fields fit together.
Using Claude Code? The MultiPaaS plugin does these steps for you.