Feat(modules-sdk,inventory,stock-location): modules isolated connection (#3329)
* feat: scoped container for modules
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import * as setup from "./schema-migrations/1665748086258-inventory_setup"
|
||||
|
||||
export default [setup]
|
||||
+1
-43
@@ -1,46 +1,4 @@
|
||||
import { ConfigModule } from "@medusajs/medusa"
|
||||
import {
|
||||
createConnection,
|
||||
ConnectionOptions,
|
||||
MigrationInterface,
|
||||
QueryRunner,
|
||||
} from "typeorm"
|
||||
|
||||
import { CONNECTION_NAME } from "../../config"
|
||||
|
||||
export const up = async ({ configModule }: { configModule: ConfigModule }) => {
|
||||
const connection = await createConnection({
|
||||
name: CONNECTION_NAME,
|
||||
type: configModule.projectConfig.database_type,
|
||||
url: configModule.projectConfig.database_url,
|
||||
extra: configModule.projectConfig.database_extra || {},
|
||||
schema: configModule.projectConfig.database_schema,
|
||||
migrations: [inventorySetup1665748086258],
|
||||
logging: true,
|
||||
} as ConnectionOptions)
|
||||
|
||||
await connection.runMigrations()
|
||||
await connection.close()
|
||||
}
|
||||
|
||||
export const down = async ({
|
||||
configModule,
|
||||
}: {
|
||||
configModule: ConfigModule
|
||||
}) => {
|
||||
const connection = await createConnection({
|
||||
name: CONNECTION_NAME,
|
||||
type: configModule.projectConfig.database_type,
|
||||
url: configModule.projectConfig.database_url,
|
||||
extra: configModule.projectConfig.database_extra || {},
|
||||
schema: configModule.projectConfig.database_schema,
|
||||
migrations: [inventorySetup1665748086258],
|
||||
logging: true,
|
||||
} as ConnectionOptions)
|
||||
|
||||
await connection.undoLastMigration({ transaction: "all" })
|
||||
await connection.close()
|
||||
}
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
export class inventorySetup1665748086258 implements MigrationInterface {
|
||||
name = "inventorySetup1665748086258"
|
||||
|
||||
Reference in New Issue
Block a user