Initial implementation with just the generate method (#7973)
This commit is contained in:
@@ -14,13 +14,13 @@ describe("defineMikroOrmCliConfig", () => {
|
||||
test("should return the correct config", () => {
|
||||
const config = defineMikroOrmCliConfig(moduleName, {
|
||||
entities: [{} as any],
|
||||
databaseName: "medusa-fulfillment",
|
||||
dbName: "medusa-fulfillment",
|
||||
})
|
||||
|
||||
expect(config).toEqual({
|
||||
entities: [{}],
|
||||
clientUrl: "postgres://postgres@localhost/medusa-fulfillment",
|
||||
type: "postgresql",
|
||||
dbName: "medusa-fulfillment",
|
||||
migrations: {
|
||||
generator: expect.any(Function),
|
||||
},
|
||||
@@ -34,8 +34,8 @@ describe("defineMikroOrmCliConfig", () => {
|
||||
|
||||
expect(config).toEqual({
|
||||
entities: [{}],
|
||||
clientUrl: "postgres://postgres@localhost/medusa-my-test",
|
||||
type: "postgresql",
|
||||
dbName: "medusa-my-test",
|
||||
migrations: {
|
||||
generator: expect.any(Function),
|
||||
},
|
||||
|
||||
@@ -17,12 +17,10 @@ type Options = Partial<Omit<MikroORMOptions, "entities" | "entitiesTs">> & {
|
||||
| EntitySchema
|
||||
| DmlEntity<any, any>
|
||||
)[]
|
||||
databaseName?: string
|
||||
}
|
||||
|
||||
type ReturnedOptions = Partial<MikroORMOptions> & {
|
||||
entities: MikroORMOptions["entities"]
|
||||
clientUrl: string
|
||||
type: MikroORMOptions["type"]
|
||||
migrations: MikroORMOptions["migrations"]
|
||||
}
|
||||
@@ -53,17 +51,11 @@ export function defineMikroOrmCliConfig(
|
||||
) as MikroORMOptions["entities"]
|
||||
|
||||
const normalizedModuleName = kebabCase(moduleName.replace("Service", ""))
|
||||
let databaseName = `medusa-${normalizedModuleName}`
|
||||
|
||||
if (options.databaseName) {
|
||||
databaseName = options.databaseName
|
||||
// @ts-ignore
|
||||
delete options.databaseName
|
||||
}
|
||||
const databaseName = `medusa-${normalizedModuleName}`
|
||||
|
||||
return {
|
||||
clientUrl: `postgres://postgres@localhost/${databaseName}`,
|
||||
type: "postgresql",
|
||||
dbName: databaseName,
|
||||
...options,
|
||||
entities,
|
||||
migrations: {
|
||||
|
||||
Reference in New Issue
Block a user