***

title: "Getting data into production"
metaTitle: "Getting Product and Catalog Data into a Production Vendure Instance"
metaDescription: "Create the database schema with an initial migration, import initial data and product catalogs, and run custom data-import scripts when deploying Vendure to production."
order: 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:

1. Creation of the database schema
2. Importing initial data like roles, tax rates, countries etc.
3. Importing catalog data like products, variants, options, facets
4. Importing other data used by your application

## Creating the initial database schema

The recommended way to create the schema for a new production deployment is to generate an initial migration locally against an empty database. This migration will contain the full database schema for your current Vendure configuration, and can then be committed to source control and run in production in the same way as all later schema changes.

To create the initial migration:

1. Point your local Vendure config at an empty database of the same type as production.
2. Keep `dbConnectionOptions.synchronize` set to `false`.
3. Generate an initial migration:

```bash
npx vendure migrate -g initial-schema
```

4. Review the generated migration file and commit it to source control.
5. Run pending migrations in production as part of your deployment process:

```bash
npx vendure migrate -r
```

If your server entry point already calls `runMigrations(config)` before `bootstrap(config)`, the committed initial migration will be applied automatically when the server starts.

### Using synchronize for the first run

Another possible way to create the schema for a brand-new, empty database is to temporarily enable TypeORM's `synchronize` feature for the first run. This is simpler, but an initial migration is preferable because it makes the production schema reproducible and auditable.

If you use this approach, enable `synchronize` with an explicit boolean environment variable:

```ts title="src/vendure-config.ts"
import { VendureConfig } from '@vendure/core';

const shouldSynchronize = process.env.DB_SYNCHRONIZE === 'true';

export const config: VendureConfig = {
    // ...
    dbConnectionOptions: {
        type: 'postgres',
        synchronize: shouldSynchronize, // [!code highlight]
        host: process.env.DB_HOST,
        port: +(process.env.DB_PORT ?? 5432),
        username: process.env.DB_USERNAME,
        password: process.env.DB_PASSWORD,
        database: process.env.DB_NAME,
    },
    // ...
};
```

Set the `DB_SYNCHRONIZE` variable to `true` on first start, and then after the schema is created, set it to `false` or remove it. Do not pass the raw environment variable directly to `synchronize`, because environment variables are strings and the string `"false"` is still truthy.

For ongoing schema changes, always use [migrations](/current/core/developer-guide/migrations/) rather than `synchronize`.

## Importing initial & catalog data

Importing initial and catalog data can be handled by Vendure `populate()` helper function - see the [Importing Product Data guide](/current/core/developer-guide/importing-data/).

## Importing other data

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](/current/core/developer-guide/stand-alone-scripts/).
