@strapi/database 5.0.0-beta.3 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5856,7 +5856,7 @@ const createStorage = (opts) => {
5856
5856
  };
5857
5857
  };
5858
5858
  const wrapTransaction = (db) => (fn) => () => {
5859
- return db.connection.transaction((trx) => Promise.resolve(fn(trx, db)));
5859
+ return db.transaction(({ trx }) => Promise.resolve(fn(trx, db)));
5860
5860
  };
5861
5861
  const migrationResolver = ({ name, path: path2, context }) => {
5862
5862
  const { db } = context;
@@ -6182,11 +6182,12 @@ const internalMigrations = [
6182
6182
  ];
6183
6183
  const createInternalMigrationProvider = (db) => {
6184
6184
  const context = { db };
6185
+ const migrations = [...internalMigrations];
6185
6186
  const umzugProvider = new Umzug({
6186
6187
  storage: createStorage({ db, tableName: "strapi_migrations_internal" }),
6187
6188
  logger: console,
6188
6189
  context,
6189
- migrations: internalMigrations.map((migration) => {
6190
+ migrations: () => migrations.map((migration) => {
6190
6191
  return {
6191
6192
  name: migration.name,
6192
6193
  up: wrapTransaction(context.db)(migration.up),
@@ -6195,6 +6196,9 @@ const createInternalMigrationProvider = (db) => {
6195
6196
  })
6196
6197
  });
6197
6198
  return {
6199
+ async register(migration) {
6200
+ migrations.push(migration);
6201
+ },
6198
6202
  async shouldRun() {
6199
6203
  const pendingMigrations = await umzugProvider.pending();
6200
6204
  return pendingMigrations.length > 0;
@@ -6208,8 +6212,13 @@ const createInternalMigrationProvider = (db) => {
6208
6212
  };
6209
6213
  };
6210
6214
  const createMigrationsProvider = (db) => {
6211
- const providers = [createUserMigrationProvider(db), createInternalMigrationProvider(db)];
6215
+ const userProvider = createUserMigrationProvider(db);
6216
+ const internalProvider = createInternalMigrationProvider(db);
6217
+ const providers = [userProvider, internalProvider];
6212
6218
  return {
6219
+ providers: {
6220
+ internal: internalProvider
6221
+ },
6213
6222
  async shouldRun() {
6214
6223
  const shouldRunResponses = await Promise.all(
6215
6224
  providers.map((provider) => provider.shouldRun())