January 2019
Intermediate to advanced
520 pages
14h 32m
English
Before we create the main function, we have to embed migrations using the embed_migrations! macro call:
embed_migrations!();
This call creates an embedded_migrations module, which contains the run function, which applies all migrations to a database. But before we use it, let's add the Config struct to read the database connection link from a configuration file or an environment variable using the config crate:
#[derive(Deserialize)]struct Config { database: Option<String>,}
This struct contains only a single parameter—the optional String with a connection link to the database. We will set this parameter later with Docker Compose using the DBSYNC_DATABASE environment variable. We have added the DBSYNC prefix in the main ...
Read now
Unlock full access