Added migrations and disabled auto-migrations to better protect users' databases
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
b8700c1ba3
commit
8119f49b4d
20
config/config.json
Normal file
20
config/config.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"development": {
|
||||
"storage": "./data/overseer.db",
|
||||
"dialect": "sqlite"
|
||||
},
|
||||
"test": {
|
||||
"username": "root",
|
||||
"password": null,
|
||||
"database": "database_test",
|
||||
"host": "127.0.0.1",
|
||||
"dialect": "mysql"
|
||||
},
|
||||
"production": {
|
||||
"username": "root",
|
||||
"password": null,
|
||||
"database": "database_production",
|
||||
"host": "127.0.0.1",
|
||||
"dialect": "mysql"
|
||||
}
|
||||
}
|
7
index.js
7
index.js
@ -8,12 +8,7 @@ const app = express();
|
||||
const config = require('config');
|
||||
|
||||
// initialize database connection
|
||||
(async () => {
|
||||
const db = require('./src/models');
|
||||
await db.sequelize.sync({
|
||||
alter: true,
|
||||
});
|
||||
})();
|
||||
const db = require('./src/models');
|
||||
|
||||
if (config.get('use_redis')) {
|
||||
// initialize Redis store for session data
|
||||
|
28
migrations/0001_add_items_table.js
Normal file
28
migrations/0001_add_items_table.js
Normal file
@ -0,0 +1,28 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('items', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
manufacturer: Sequelize.DataTypes.STRING,
|
||||
serialNumber: Sequelize.DataTypes.STRING,
|
||||
skuNumber: Sequelize.DataTypes.STRING,
|
||||
type: Sequelize.DataTypes.STRING,
|
||||
purchasedFrom: Sequelize.DataTypes.STRING,
|
||||
purchasedAt: Sequelize.DataTypes.DATE,
|
||||
createdAt: Sequelize.DataTypes.DATE,
|
||||
updatedAt: Sequelize.DataTypes.DATE,
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('items');
|
||||
}
|
||||
};
|
37
migrations/0002_add_licenses_table.js
Normal file
37
migrations/0002_add_licenses_table.js
Normal file
@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('licenses', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
key: {
|
||||
type: Sequelize.DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
manufacturer: Sequelize.DataTypes.STRING,
|
||||
seatsUsed: {
|
||||
type: Sequelize.DataTypes.NUMBER,
|
||||
defaultValue: 0,
|
||||
},
|
||||
seatsTotal: {
|
||||
type: Sequelize.DataTypes.NUMBER,
|
||||
defaultValue: 1,
|
||||
},
|
||||
purchasedFrom: Sequelize.DataTypes.STRING,
|
||||
purchasedAt: Sequelize.DataTypes.DATE,
|
||||
createdAt: Sequelize.DataTypes.DATE,
|
||||
updatedAt: Sequelize.DataTypes.DATE,
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('licenses');
|
||||
}
|
||||
};
|
30
migrations/0003_add_activities_table.js
Normal file
30
migrations/0003_add_activities_table.js
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('activities', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
user: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
action: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
itemId: {
|
||||
type: Sequelize.NUMBER,
|
||||
allowNull: false,
|
||||
},
|
||||
createdAt: Sequelize.DataTypes.DATE,
|
||||
updatedAt: Sequelize.DataTypes.DATE,
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('activities');
|
||||
}
|
||||
};
|
997
package-lock.json
generated
997
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@
|
||||
"start": "node index.js",
|
||||
"grunt": "grunt",
|
||||
"nodemon": "nodemon index.js",
|
||||
"sequelize": "sequelize-cli",
|
||||
"lint": "eslint index.js src/**/*.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
@ -49,6 +50,7 @@
|
||||
"pg-hstore": "^2.3.4",
|
||||
"redis": "^4.4.0",
|
||||
"sequelize": "^6.25.3",
|
||||
"sequelize-cli": "^6.5.2",
|
||||
"sqlite3": "^5.1.2",
|
||||
"twig": "^1.15.4"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user