title | showtoc | weight |
---|---|---|
Getting data into production |
true |
4 |
Once you have set up your production deployment, you'll need some way to get your products and other data into the system.
The main tasks will be:
- Creation of the database schema
- Importing initial data like roles, tax rates, countries etc.
- Importing catalog data like products, variants, options, facets
- Importing other data used by your application
The first item - creation of the schema - can be automatically handled by TypeORM's synchronize
feature. Switching it on for the initial
run will automatically create the schema. This can be done by using an environment variable:
import { VendureConfig } from '@vendure/core';
export const config: VendureConfig = {
// ...
dbConnectionOptions: {
type: 'postgres',
// highlight-next-line
synchronize: process.env.DB_SYNCHRONIZE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
},
// ...
};
Set the DB_SYNCHRONIZE
variable to true
on first start, and then after the schema is created, set it to false
.
Importing initial and catalog data can be handled by Vendure populate()
helper function - see the Importing Product Data guide.
Any kinds of data not covered by the populate()
function can be imported using a custom script, which can use any Vendure service or service defined by your custom plugins to populate data in any way you like. See the Stand-alone scripts guide.