Added a quick exit for migrations if the database is new
This commit is contained in:
@@ -1,15 +1,23 @@
|
|||||||
import { Migrations } from 'meteor/percolate:migrations';
|
import { Migrations } from 'meteor/percolate:migrations';
|
||||||
import SCHEMA_VERSION from '/imports/constants/SCHEMA_VERSION.js';
|
import SCHEMA_VERSION from '/imports/constants/SCHEMA_VERSION.js';
|
||||||
|
|
||||||
if (Meteor.isServer){
|
if (Meteor.isServer) {
|
||||||
Meteor.startup(()=>{
|
Meteor.startup(() => {
|
||||||
const dbVersion = Migrations.getVersion();
|
const dbVersion = Migrations.getVersion();
|
||||||
|
// If there are no users, this is a new DB, set the version to latest
|
||||||
|
const aUser = Meteor.users.findOne({});
|
||||||
|
const latestVersion = Migrations._list[Migrations._list.length - 1].version
|
||||||
|
if (!aUser && dbVersion !== latestVersion) {
|
||||||
|
Migrations._collection.update({ _id: 'control' }, { version: latestVersion });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Otherwise put the app in maintenance mode if it's not the right version
|
||||||
if (
|
if (
|
||||||
!Meteor.settings.public.maintenanceMode &&
|
!Meteor.settings.public.maintenanceMode &&
|
||||||
dbVersion !== undefined &&
|
dbVersion !== undefined &&
|
||||||
SCHEMA_VERSION !== dbVersion
|
SCHEMA_VERSION !== dbVersion
|
||||||
){
|
) {
|
||||||
Meteor.settings.public.maintenanceMode = {
|
Meteor.settings.public.maintenanceMode = {
|
||||||
reason: 'App data needs to be migrated to the latest version'
|
reason: 'App data needs to be migrated to the latest version'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user