Skip to content

Load demo data and bind logins to records

An application can carry the rows that an organization starts with. You write one CSV file for each table in a seed directory of the application. matterdata install -seed loads them when it creates the organization. matterdata install -login creates several logins at the same time, and each login can be bound to its own row.

This is for demonstrations, trials and first installations. It runs once, when the organization is created. To change the data of an organization that exists, use the application’s own pages.

Put the files in seed/ inside the application directory. A file is named after the table, as you write the table in schema.mtd:

time-tracking/
app.mtd
schema.mtd
seed/
customers.csv
projects.csv
employees.csv
time_entries.csv

The first line names the columns. Each name is id or the name of a field of the table:

seed/customers.csv
name
Acme Logistics
Nordwind Energie
seed/projects.csv
code,name,customer
ACM-ERP,ERP migration,1
NRD-GRID,Grid data platform,2

A ref field holds the id of a row of the table it points to. customer above is the id of a row in customers.csv. Without an id column, the first row has id 1, the second row has id 2, and so on. Add an id column when you want to name a row yourself, for example one that a login will be bound to:

seed/employees.csv
id,first_name,last_name,email,manager
1,Bianca,Backoffice,backoffice@tt.example,
4,Carla,Consultant,consultant@tt.example,1

A row may point to a row of its own table, like manager above. A row may also point to a row that comes later in the same file.

A cell is read by the same code that reads a form field, in the English notation. The language of the application does not change it.

Field Write Example
text, long_text, markdown, email the text Review and testing
slug nothing: leave the column out; the loader writes the address
int digits, with an optional sign 90
decimal(n), money digits with a point, at most n places 14.5
date YYYY-MM-DD 2026-09-30
datetime a date and a time in the zone of the application, or with an offset 2026-09-30T09:00
bool true, false, yes, no, 1 or 0 true
enum one of the declared values senior
ref the id of a row of the target table 4

A cell with a comma, a quote or a line break is enclosed in double quotes. A double quote inside it is written twice: "He said ""yes""".

An empty cell means no value. If you leave a column out of the header, its default: applies. Leave a required column out, and the loader refuses the file.

A table with a lifecycle can name its state column. Its values are the states of the lifecycle. Without that column, each row starts in the default state. A table in the application scope names its scope column, because no person is signed in to give it a value.

Terminal window
matterdata validate time-tracking

validate compiles the application, and then loads the seed into a scratch database that it deletes at the end. It uses the same loader as install. A seed that passes validate loads. Each problem is one line with the position of the cell:

time-tracking/seed/projects.csv:3:14: customer refers to customers row 9, which seed/customers.csv does not define (it defines 3 rows)
time-tracking/seed/time_entries.csv:12:4: minutes: At least 1.
time-tracking/seed/employees.csv:1:40: table "employees" has no column "nom"; the columns are id, first_name, last_name, email, manager

The first 20 problems are listed. A file with one bad cell refuses the whole seed, so the check is also the list of what to fix.

The loader checks each row the way a form does:

  • the type, the length, the bounds and the declared values of each field;
  • required, and the check and require … when rules of the table, with the message you wrote;
  • that each ref names a row that the seed defines, and that a unique value is not repeated.

It writes created_at and updated_at with the time of the installation. created_by and updated_by stay empty. The loader may write a sensitive column, because the person who installs has every grant.

The loader does not run hooks. A seed must give the same organization every time, and a hook can use the clock and call other systems. Write the value of a column that a hook derives in the file. The loader writes no audit event either: the audit log records what people did to an organization that runs.

Terminal window
matterdata install -dir data -tenant tt -app time-tracking -seed \
-login backoffice@tt.example:backoffice:employee=1 \
-login manager@tt.example:manager,consultant:employee=2 \
-login consultant@tt.example:consultant:employee=4 < passwords.txt

-login is written <email>:<role>[,<role>…][:<profile>=<row id>[,<profile>=<row id>…]], and you can repeat it. The profile name is one that the auth block declares, and the row id is the id of a row in the seed. Read Profile for what a profile does.

Put one password per line in a private passwords.txt file. Keep it out of version control and remove it after installation. install reads the -email password first, then one line for each -login, in flag order. A missing or empty line refuses the install.

You can also set MTD_LOGIN_PASSWORD through your secret manager. Its value takes precedence over standard input and gives every login the same password. Avoid typing a secret into a shell command: shell history can retain it. If you enter passwords at the terminal, the terminal shows what you type.

The first login created is the administrator of the organization: the -email login, or otherwise the first -login. -email, -role and -profile still work. -password is refused before any tenant is written.

Every refusal happens before a file is written:

You ran What happens
-seed for an application with no seed/*.csv refused, naming the directory
-seed with a bad cell refused with file:line:column. No tenant file exists afterward
-seed with -demo refused. Both write rows into the same tables
-login with a role the application does not declare refused, listing the roles it declares
-login with a profile that does not serve the role, or that the application does not declare refused, naming the profiles and roles
the same address twice refused
no password in the variable or on standard input refused, naming MTD_LOGIN_PASSWORD

-seed also works when you add an application to an organization that exists, and then it loads only the new application. -login does not: create the login on the administration page first. See Add a second application to an organization.

A seed loads into empty tables only. Running the loader on a table that has rows is refused, and it names the table. To start again, create the organization again. A demonstration organization that resets every night returns to the state it had after the seed. See Reset a demonstration organization every night.

A tenant administrator can change the row of a login at any time. See Bind a login to a record.

  • A table with an unguessable field or a versioned column cannot be seeded yet. The loader says which field is the reason.
  • A slug is derived from the row’s other cells, as it is when a form saves a row. Leave the slug column out of the header. A name that is taken becomes name-2, and a name that the application uses for a page is skipped; naming the column in the header is refused.
  • The links of a multi field cannot be seeded. Naming one in the header is refused.
  • A computed field cannot be written, and its name in a header is refused.

Website privacy policy