mirror of
https://github.com/knex/knex.git
synced 2025-12-26 22:48:32 +00:00
disable_migrations_list_validation_feature (#3448)
This commit is contained in:
parent
4a71315e9c
commit
6b9fb0ec01
@ -65,7 +65,9 @@ class Migrator {
|
||||
return migrationListResolver
|
||||
.listAllAndCompleted(this.config, this.knex)
|
||||
.then((value) => {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
if (!this.config.disableMigrationsListValidation) {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
}
|
||||
return value;
|
||||
})
|
||||
.then(([all, completed]) => {
|
||||
@ -104,7 +106,9 @@ class Migrator {
|
||||
return migrationListResolver
|
||||
.listAllAndCompleted(this.config, this.knex)
|
||||
.then((value) => {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
if (!this.config.disableMigrationsListValidation) {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
}
|
||||
return value;
|
||||
})
|
||||
.then(([all, completed]) => {
|
||||
@ -170,7 +174,9 @@ class Migrator {
|
||||
migrationListResolver
|
||||
.listAllAndCompleted(this.config, this.knex)
|
||||
.then((value) => {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
if (!this.config.disableMigrationsListValidation) {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
}
|
||||
return value;
|
||||
})
|
||||
.then((val) => {
|
||||
@ -198,7 +204,9 @@ class Migrator {
|
||||
return migrationListResolver
|
||||
.listAllAndCompleted(this.config, this.knex)
|
||||
.then((value) => {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
if (!this.config.disableMigrationsListValidation) {
|
||||
validateMigrationList(this.config.migrationSource, value);
|
||||
}
|
||||
return value;
|
||||
})
|
||||
.then(([all, completed]) => {
|
||||
@ -267,7 +275,10 @@ class Migrator {
|
||||
this.config,
|
||||
this.knex
|
||||
);
|
||||
validateMigrationList(this.config.migrationSource, [all, completed]);
|
||||
|
||||
if (!this.config.disableMigrationsListValidation) {
|
||||
validateMigrationList(this.config.migrationSource, [all, completed]);
|
||||
}
|
||||
|
||||
const newMigrations = getNewMigrations(
|
||||
this.config.migrationSource,
|
||||
|
||||
@ -10,6 +10,7 @@ const CONFIG_DEFAULT = Object.freeze({
|
||||
schemaName: null,
|
||||
directory: './migrations',
|
||||
disableTransactions: false,
|
||||
disableMigrationsListValidation: false,
|
||||
sortDirsSeparately: false,
|
||||
});
|
||||
|
||||
|
||||
@ -1036,4 +1036,25 @@ module.exports = function(knex) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('knex.migrate.latest with disableValidateMigrationList', function() {
|
||||
it('should not fail if there is a missing migration', () => {
|
||||
return knex.migrate
|
||||
.latest({
|
||||
directory: 'test/integration/migrate/test',
|
||||
})
|
||||
.then(() => {
|
||||
return knex.migrate.latest({
|
||||
directory:
|
||||
'test/integration/migrate/test_with_missing_first_migration',
|
||||
disableMigrationsListValidation: true,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
return knex.migrate.rollback({
|
||||
directory: 'test/integration/migrate/test',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
exports.up = function(knex, promise) {
|
||||
const tableName2 = knex.userParams.customTableName || 'migration_test_2_1';
|
||||
return knex.schema
|
||||
.createTable('migration_test_2', function(t) {
|
||||
t.increments();
|
||||
t.string('name');
|
||||
})
|
||||
.then(() =>
|
||||
knex.schema.createTable(tableName2, function(t) {
|
||||
t.increments();
|
||||
t.string('name');
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
return knex.schema.table('migration_test_1', function(t) {
|
||||
t.integer('age');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex, promise) {
|
||||
const tableName2 = knex.userParams.customTableName || 'migration_test_2_1';
|
||||
return knex.schema
|
||||
.dropTable('migration_test_2')
|
||||
.then(() => knex.schema.dropTable(tableName2))
|
||||
.then(() => {
|
||||
return knex.schema.table('migration_test_1', function(t) {
|
||||
t.dropColumn('age');
|
||||
});
|
||||
});
|
||||
};
|
||||
1
types/index.d.ts
vendored
1
types/index.d.ts
vendored
@ -1810,6 +1810,7 @@ declare namespace Knex {
|
||||
tableName?: string;
|
||||
schemaName?: string;
|
||||
disableTransactions?: boolean;
|
||||
disableMigrationsListValidation?: boolean;
|
||||
sortDirsSeparately?: boolean;
|
||||
loadExtensions?: string[];
|
||||
migrationSource?: any;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user