typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

Synchronize does not create postgres schema

Open antoine-pous opened this issue 2 years ago • 1 comments

Issue description

Synchronize does not create postgres schema

Expected Behavior

When we specify a schema on an @Entity the ORM must try to create the schema while Synchronize is enabled. I never use the public one.

Actual Behavior

Currently this kind of Entity declaration does not create the schema if it does not exists.

@Entity({schema: 'schema_test', name: 'table_test'})

Steps to reproduce

test.entity.ts

@Entity({schema: 'schema_test', name: 'table_test'})
class TestEntity {
  @Column()
  name: string
}

database.ts

const database = new DataSource({
  type: "postgres"
  , host: env.POSTGRES_HOST
  , port: env.POSTGRES_PORT
  , username: env.POSTGRES_USER
  , password: env.POSTGRES_PASS
  , database: env.POSTGRES_DB
  , synchronize: true
  , logging: true
  , entities: [
    'src/database/entities/**/*.entity.ts'
  ]
  , subscribers: []
  , migrations: []
})
``

### My Environment

| Dependency          | Version  |
| ---                 | ---      |
| Operating System    |  Ubuntu 22.04 // MacOS 13.4.1  |
| Node.js version     | 18.16.1  |
| Typescript version  | 5.6.1  |
| TypeORM version     | 0.3.17 |


### Additional Context

_No response_

### Relevant Database Driver(s)

- [ ] aurora-mysql
- [ ] aurora-postgres
- [ ] better-sqlite3
- [ ] cockroachdb
- [ ] cordova
- [ ] expo
- [ ] mongodb
- [ ] mysql
- [ ] nativescript
- [ ] oracle
- [X] postgres
- [ ] react-native
- [ ] sap
- [ ] spanner
- [ ] sqlite
- [ ] sqlite-abstract
- [ ] sqljs
- [ ] sqlserver

### Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

antoine-pous avatar Jul 06 '23 22:07 antoine-pous

i have same issue, did you find any solutions without migration?

selamsc avatar Feb 09 '24 08:02 selamsc