Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the 'sync.force' to true or false when the environment is development or production? #200

Closed
gzlock opened this issue Jul 1, 2020 · 1 comment

Comments

@gzlock
Copy link

gzlock commented Jul 1, 2020

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I used @nestjs/config to get the env is development or production
And used the @nestjs/sequelize to create the sequelize instance
It look like the document

import { Module } from '@nestjs/common';
import { SequelizeModule } from '@nestjs/sequelize';

@Module({
  imports: [
    SequelizeModule.forRoot({
      dialect: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: 'root',
      database: 'test',
      autoLoadModels: true,
      synchronize: true,
      sync: { force: true },
    }),
  ],
})
export class AppModule {}

Expected behavior

I want to set the sync: { force: false } when the environment is 'production'
and set sync: { force: true } when the environment is 'development'

Minimal reproduction of the problem with instructions

null

What is the motivation / use case for changing the behavior?

null

Environment

Nest version: ^7.0.0

For Tooling issues:

  • Node version: v12.18.1
  • Platform: macOS

Others:
@nestjs/sequelize: ^0.1.0,
@nestjs/config": ^0.5.0,

@kamilmysliwiec
Copy link
Member

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants