overleaf/services/clsi/app/coffee/db.coffee

40 lines
855 B
CoffeeScript
Raw Normal View History

2014-02-12 12:27:43 -05:00
Sequelize = require("sequelize")
Settings = require("settings-sharelatex")
_ = require("underscore")
2018-03-05 11:02:16 -05:00
logger = require "logger-sharelatex"
options = _.extend {logging:false}, Settings.mysql.clsi
2014-02-12 12:27:43 -05:00
sequelize = new Sequelize(
Settings.mysql.clsi.database,
Settings.mysql.clsi.username,
Settings.mysql.clsi.password,
options
2014-02-12 12:27:43 -05:00
)
module.exports =
UrlCache: sequelize.define("UrlCache", {
url: Sequelize.STRING
project_id: Sequelize.STRING
lastModified: Sequelize.DATE
2015-05-15 09:05:17 -04:00
}, {
indexes: [
{fields: ['url', 'project_id']},
{fields: ['project_id']}
]
2014-02-12 12:27:43 -05:00
})
Project: sequelize.define("Project", {
2015-05-15 09:05:17 -04:00
project_id: {type: Sequelize.STRING, primaryKey: true}
2014-02-12 12:27:43 -05:00
lastAccessed: Sequelize.DATE
2015-05-15 09:05:17 -04:00
}, {
indexes: [
{fields: ['lastAccessed']}
]
2014-02-12 12:27:43 -05:00
})
2018-03-05 11:02:16 -05:00
sync: () ->
logger.log dbPath:Settings.mysql.clsi.storage, "syncing db schema"
sequelize.sync()
2014-02-12 12:27:43 -05:00