Open libterty opened 3 years ago
I don't use Postgres but from what I'm reading Postgres behaves a lot like Oracle so I think your problem is the schema. The two different users are likely using their own schemas when connecting instead of a shared or the public schema. The TypeORM documentation doesn't go into each database's structural functionality and it shouldn't unless directly impacting the code that we need to write - and schemas don't impact our code, just how we connect, so I wouldn't say the documentation is incomplete.
But then coming back to the point: are you sure both users are using the same schema?
@lflfm
Yes both users using the same schema, the configuration is like. So that's why i'm confusing about why same schema would retrigger migration when it use different db user
const masterConfig: Partial<ConnectionOptions> = {
host: config.TYPEORM.MASTER_HOST,
port: config.TYPEORM.MASTER_PORT,
username: config.TYPEORM.MASTER_USERNAME,
password: config.TYPEORM.MASTER_PASSWORD,
database: config.TYPEORM.MASTER_DB
}
export const ormConfig: ConnectionOptions = {
...
type: config.TYPEORM.MASTER_CONNECTION,
host: config.TYPEORM.MASTER_HOST,
port: config.TYPEORM.MASTER_PORT,
username: config.TYPEORM.MASTER_USERNAME,
password: config.TYPEORM.MASTER_PASSWORD,
database: config.TYPEORM.MASTER_DB,
schema: config.TYPEORM.MASTER_SCHEMA
...
replication: {
master: masterConfig,
slaves: [...]
}
}
Hi, I've been having this problem. It occurred because migrations dir contained the index.ts
file that exported the migrations classes. The migrations loader loads the classes from each file, and then loads again from the index file.
I hope this helps.
Issue Description
When I try to run migration the orm didn't detect that the same migration has already been generated and executed before.
Expected Behavior
Expect orm could detect same migration for same database under different role
Actual Behavior
Orm didn't detect different user role with same migration, like following example entity. If i have user
Postgres
andTest
inTest
database. And project one usePostgres
to create migration while project two useTest
to create migration. One of the migration would fails due to migration is already been executed. Later on I found out I have to execute migration with same user so that migration script will not meet duplicate create. I'm not sure if this is just not documented or it's a bug.Steps to Reproduce
My Environment
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?