mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-05 19:05:18 +02:00
Server db utils changes
This commit is contained in:
parent
91e99e1bcc
commit
d86ebe3e58
5 changed files with 36 additions and 21 deletions
|
@ -1,12 +1,12 @@
|
|||
const fs = require('fs');
|
||||
const { slugify } = require('./slugify');
|
||||
|
||||
const backupDB = () => {
|
||||
if (!fs.existsSync('data/db_backups')) {
|
||||
fs.mkdirSync('data/db_backups');
|
||||
}
|
||||
|
||||
const version = process.env.VERSION;
|
||||
const slug = `db-${version.replace(/\./g, '')}-backup.sqlite`;
|
||||
const slug = slugify();
|
||||
|
||||
const srcPath = 'data/db.sqlite';
|
||||
const destPath = `data/db_backups/${slug}`;
|
||||
|
|
19
db/utils/slugify.js
Normal file
19
db/utils/slugify.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const slugify = () => {
|
||||
const version = process.env.VERSION;
|
||||
const slug = `db-${version.replace(/\./g, '')}-backup.sqlite`;
|
||||
return slug;
|
||||
};
|
||||
|
||||
const parseSlug = (slug) => {
|
||||
const parts = slug.split('-');
|
||||
const version = {
|
||||
raw: parts[1],
|
||||
parsed: parts[1].split('').join('.'),
|
||||
};
|
||||
return version;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
slugify,
|
||||
parseSlug,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue