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

A way to provide schema migration in dev startup #30

Closed
ghost opened this issue Aug 25, 2019 · 6 comments
Closed

A way to provide schema migration in dev startup #30

ghost opened this issue Aug 25, 2019 · 6 comments
Labels
enhancement New feature or request Feature New feature

Comments

@ghost
Copy link

ghost commented Aug 25, 2019

A way to include mongodb in prod with db migration schema

@ghost ghost added the enhancement New feature or request label Aug 25, 2019
@ghost
Copy link
Author

ghost commented Aug 26, 2019

Remember that, according the answer, it will be a prod db connection with sqlite (or mongodb)..

``
const defaultOptions = {
type: 'postgres',
port: 5432,
username: 'user',
password: 'password',
database: 'db',
synchronize: true,
};

@module({
imports: [
TypeOrmModule.forRoot({
...defaultOptions,
host: 'photo_db_host',
entities: [Photo],
})
``
So, according the environment (dev or prod), the connection must be changed. Please attention that in dev mode there is always the sqlite db.

@ghost ghost self-assigned this Aug 26, 2019
@ghost ghost added the Feature New feature label Aug 26, 2019
@ghost ghost changed the title A Prompt question to include mongodb (optional) A Prompt question to include mongodb with schema migration in dev startup Aug 26, 2019
@ghost
Copy link
Author

ghost commented Aug 26, 2019

The issue is not more an optional, because we have to provide a migration with typeORM for scripts in dev mode running for sqlite

@ghost
Copy link
Author

ghost commented Sep 2, 2019

Consider feature/migration-db and this src/ormconfig.ts:

import { ConnectionOptions } from 'typeorm'; const config: ConnectionOptions = {  type: 'postgres',  host: process.env.POSTGRES_HOST,  port: Number(process.env.POSTGRES_PORT),  username: process.env.POSTGRES_USER,  password: process.env.POSTGRES_PASSWORD,  database: process.env.POSTGRES_DB,  entities: [    __dirname + '/../**/*.entity{.ts,.js}',  ],  cli: {    migrationsDir: 'src/migrations',  }}; export = config;

@deepu105
Copy link
Member

deepu105 commented Sep 2, 2019 via email

@ghost
Copy link
Author

ghost commented Sep 2, 2019

Hi @deepu105,
now for this blueprint, in the server generator there are only two questions: serverPort and mongoProdDatabase . The other prompts questions for the server generation are been delated, because in this blueprint they haven't sense to be due to their java spring meaning. So if you answer to yes for the mongoProdDatabase there will generated the config for this, otherwise the sqlite is the default. So be sure that there aren't other database questions. For this I have renamed the issue. If it is not clear, feel free to ask me.

@ghost ghost changed the title A Prompt question to include mongodb with schema migration in dev startup A way to provide schema migration in dev startup Sep 2, 2019
@deepu105
Copy link
Member

deepu105 commented Sep 2, 2019 via email

@ghost ghost mentioned this issue Sep 3, 2019
@ghost ghost closed this as completed Sep 3, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant