mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
fixed usage of migrations
Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
94c3857d49
commit
6480c142a9
3 changed files with 31 additions and 10 deletions
|
@ -1,8 +1,31 @@
|
||||||
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
const envs = ['development', 'test', 'production'];
|
||||||
|
|
||||||
|
if (!fs.existsSync(path.resolve('config'))) {
|
||||||
|
fs.mkdirSync(path.resolve('config'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const configJson = JSON.parse(fs.readFileSync('config.json'));
|
||||||
|
|
||||||
|
let database = {};
|
||||||
|
envs.forEach(function (env, i) {
|
||||||
|
if (configJson[env]) {
|
||||||
|
database[env] = {
|
||||||
|
...configJson[env].db
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.writeFile(path.resolve('config', 'database.json'), JSON.stringify(database), 'utf8', function (err) {
|
||||||
|
if (err) {
|
||||||
|
console.log("An error occured while writing JSON Object to File.");
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'config': path.resolve('config.json'),
|
'config': path.resolve('config', 'database.json'),
|
||||||
'migrations-path': path.resolve('lib', 'migrations'),
|
'migrations-path': path.resolve('lib', 'migrations'),
|
||||||
'models-path': path.resolve('lib', 'models'),
|
'models-path': path.resolve('lib', 'models')
|
||||||
'url': 'change this'
|
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
const isSQLite = require('../utils').isSQLite
|
function isSQLite (sequelize) {
|
||||||
|
return sequelize.options.dialect === 'sqlite'
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: function (queryInterface, Sequelize) {
|
up: function (queryInterface, Sequelize) {
|
||||||
return queryInterface.changeColumn('Notes', 'title', {
|
return queryInterface.changeColumn('Notes', 'title', {
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import { Sequelize } from 'sequelize-typescript'
|
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
import { realtime } from './realtime'
|
import { realtime } from './realtime'
|
||||||
import { config } from './config'
|
import { config } from './config'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { Revision } from './models'
|
import { Revision } from './models'
|
||||||
|
|
||||||
export function isSQLite (sequelize: Sequelize): boolean {
|
|
||||||
return sequelize.options.dialect === 'sqlite'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getImageMimeType (imagePath: string): string | undefined {
|
export function getImageMimeType (imagePath: string): string | undefined {
|
||||||
const fileExtension = /[^.]+$/.exec(imagePath)
|
const fileExtension = /[^.]+$/.exec(imagePath)
|
||||||
switch (fileExtension?.[0]) {
|
switch (fileExtension?.[0]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue