mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 18:23:32 -05:00
41 lines
922 B
CoffeeScript
41 lines
922 B
CoffeeScript
Sequelize = require("sequelize")
|
|
Settings = require("settings-sharelatex")
|
|
_ = require("underscore")
|
|
logger = require "logger-sharelatex"
|
|
|
|
options = _.extend {logging:false}, Settings.mysql.clsi
|
|
|
|
logger.log dbPath:Settings.mysql.clsi.storage, "connecting to db"
|
|
|
|
sequelize = new Sequelize(
|
|
Settings.mysql.clsi.database,
|
|
Settings.mysql.clsi.username,
|
|
Settings.mysql.clsi.password,
|
|
options
|
|
)
|
|
|
|
module.exports =
|
|
UrlCache: sequelize.define("UrlCache", {
|
|
url: Sequelize.STRING
|
|
project_id: Sequelize.STRING
|
|
lastModified: Sequelize.DATE
|
|
}, {
|
|
indexes: [
|
|
{fields: ['url', 'project_id']},
|
|
{fields: ['project_id']}
|
|
]
|
|
})
|
|
|
|
Project: sequelize.define("Project", {
|
|
project_id: {type: Sequelize.STRING, primaryKey: true}
|
|
lastAccessed: Sequelize.DATE
|
|
}, {
|
|
indexes: [
|
|
{fields: ['lastAccessed']}
|
|
]
|
|
})
|
|
|
|
sync: () ->
|
|
logger.log dbPath:Settings.mysql.clsi.storage, "syncing db schema"
|
|
sequelize.sync()
|
|
|