refactor: migrate to PostgreSQL + Sequelize

This commit is contained in:
NGPixel
2017-07-22 23:56:46 -04:00
parent 8da98ce75a
commit d76f6182b2
40 changed files with 1044 additions and 745 deletions

44
server/models/file.js Normal file
View File

@@ -0,0 +1,44 @@
'use strict'
/**
* File schema
*/
module.exports = (sequelize, DataTypes) => {
let fileSchema = sequelize.define('file', {
category: {
type: DataTypes.ENUM('binary', 'image'),
allowNull: false,
defaultValue: 'binary'
},
mime: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'application/octet-stream'
},
extra: {
type: DataTypes.JSONB,
allowNull: true
},
filename: {
type: DataTypes.STRING,
allowNull: false
},
basename: {
type: DataTypes.STRING,
allowNull: false
},
filesize: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
isInt: true,
min: 0
}
}
}, {
timestamps: true,
version: true
})
return fileSchema
}