Your development database now holds the data you moved over from K1 in lesson 2.4.7: a dozen contacts, a few appointments. For much of what comes next, that is too little. A list with pages (lesson 2.3.10) shows a second page only with many contacts, a search (lesson 2.4.9) is interesting only with many names, and the weekly calendar in module 2.5 needs appointments in this week and the next, not sometime in the past.
Nobody types such data by hand. A seed creates it: code that fills the database with data as soon as it has its tables. In this lesson the Kladde gets a seed with 50 invented contacts and 200 appointments, for development only, and one command rebuilds the database with it at any time.
Only invented data
Before we get to code, a rule that holds for the whole academy: development and tests contain only invented data. Never a copy of real data, not “just for a moment” and not “just the names”. There are solid reasons:
- Data leaves its protection. A development database lives in the codespace, on laptops, in backups, in screenshots for a pull request, in logs with sensitive values (lesson 2.4.9). Nobody guards it the way they guard the production database.
- Data does things. From lesson 2.8.5, the Kladde sends emails. With real addresses in development, a real customer will eventually get a test email with the subject “asdf”.
- Personal data is protected. What data about people may be used for is governed by data protection law, and you don’t decide that question in the codespace. With invented data it doesn’t even arise.
Invented data still looks real enough if you pay attention to a few things:
- Addresses ending in
.example. The endings.example,.testand.invalidare reserved for examples and tests and belong to no one. An email toanna.berger@testdata.examplenever reaches a person. - Names from lists, combined by a fixed rule. That way every run is the same, and a test can rely on the data.
- Company names that don’t exist. As throughout the course: Kranich Software, Lindenhof Practice, Harbor Office East.