fix(integration): setup (#5511)

* fix(integration): setup
This commit is contained in:
Adrien de Peretti
2023-11-01 13:56:12 -04:00
committed by GitHub
parent 4692f54b49
commit 80fe362f33
45 changed files with 461 additions and 405 deletions
@@ -21,14 +21,13 @@ const pgGodCredentials = {
class DatabaseFactory {
constructor() {
this.dataSource_ = null
this.masterDataSourceName = "master"
this.templateDbName = "medusa-integration-template"
}
async createTemplateDb_({ cwd }) {
const { configModule } = getConfigFile(cwd, `medusa-config`)
const dataSource = await this.getMasterDataSource()
const migrationDir = path.resolve(
path.join(
__dirname,
@@ -80,8 +79,6 @@ class DatabaseFactory {
await templateDbDataSource.runMigrations()
await templateDbDataSource.destroy()
return dataSource
}
async getMasterDataSource() {
@@ -103,7 +100,7 @@ class DatabaseFactory {
async createFromTemplate(dbName) {
const dataSource = await this.getMasterDataSource()
await dataSource.query(`DROP DATABASE IF EXISTS "${dbName}";`)
await dropDatabase({ databaseName: dbName }, pgGodCredentials)
await dataSource.query(
`CREATE DATABASE "${dbName}" TEMPLATE "${this.templateDbName}";`
)