mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
make a special backup before migrating to 0.60
This commit is contained in:
parent
64db5e2542
commit
291f0e79d9
@ -7,11 +7,6 @@ const resourceDir = require('./resource_dir');
|
|||||||
const appInfo = require('./app_info');
|
const appInfo = require('./app_info');
|
||||||
|
|
||||||
async function migrate() {
|
async function migrate() {
|
||||||
const migrations = [];
|
|
||||||
|
|
||||||
// backup before attempting migration
|
|
||||||
await backupService.backupNow("before-migration");
|
|
||||||
|
|
||||||
const currentDbVersion = getDbVersion();
|
const currentDbVersion = getDbVersion();
|
||||||
|
|
||||||
if (currentDbVersion < 183) {
|
if (currentDbVersion < 183) {
|
||||||
@ -21,27 +16,35 @@ async function migrate() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readdirSync(resourceDir.MIGRATIONS_DIR).forEach(file => {
|
// backup before attempting migration
|
||||||
|
await backupService.backupNow(
|
||||||
|
// special name for the pre-0.60 migration to prevent later overwrite
|
||||||
|
currentDbVersion < 214
|
||||||
|
? `before-migration-v${currentDbVersion}`
|
||||||
|
: 'before-migration'
|
||||||
|
);
|
||||||
|
|
||||||
|
const migrations = fs.readdirSync(resourceDir.MIGRATIONS_DIR).map(file => {
|
||||||
const match = file.match(/^([0-9]{4})__([a-zA-Z0-9_ ]+)\.(sql|js)$/);
|
const match = file.match(/^([0-9]{4})__([a-zA-Z0-9_ ]+)\.(sql|js)$/);
|
||||||
|
if (!match) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (match) {
|
|
||||||
const dbVersion = parseInt(match[1]);
|
const dbVersion = parseInt(match[1]);
|
||||||
|
|
||||||
if (dbVersion > currentDbVersion) {
|
if (dbVersion > currentDbVersion) {
|
||||||
const name = match[2];
|
const name = match[2];
|
||||||
const type = match[3];
|
const type = match[3];
|
||||||
|
|
||||||
const migrationRecord = {
|
return {
|
||||||
dbVersion: dbVersion,
|
dbVersion: dbVersion,
|
||||||
name: name,
|
name: name,
|
||||||
file: file,
|
file: file,
|
||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
migrations.push(migrationRecord);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}).filter(el => !!el);
|
||||||
});
|
|
||||||
|
|
||||||
migrations.sort((a, b) => a.dbVersion - b.dbVersion);
|
migrations.sort((a, b) => a.dbVersion - b.dbVersion);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user