Added server wide audiobook rating (admin only)

This commit is contained in:
Peter BALIVET 2025-06-27 11:02:42 +02:00
parent d21fe49ce2
commit 7c3504fe2b
10 changed files with 312 additions and 18 deletions

View file

@ -0,0 +1,58 @@
const { DataTypes } = require('sequelize')
module.exports = {
up: async ({ context: queryInterface }) => {
const transaction = await queryInterface.sequelize.transaction()
try {
await queryInterface.addColumn(
'books',
'rating',
{
type: DataTypes.FLOAT
},
{ transaction }
)
await queryInterface.addColumn(
'books',
'providerRating',
{
type: DataTypes.FLOAT
},
{ transaction }
)
await queryInterface.addColumn(
'books',
'provider',
{
type: DataTypes.STRING
},
{ transaction }
)
await queryInterface.addColumn(
'books',
'providerId',
{
type: DataTypes.STRING
},
{ transaction }
)
await transaction.commit()
} catch (err) {
await transaction.rollback()
throw err
}
},
down: async ({ context: queryInterface }) => {
const transaction = await queryInterface.sequelize.transaction()
try {
await queryInterface.removeColumn('books', 'rating', { transaction })
await queryInterface.removeColumn('books', 'providerRating', { transaction })
await queryInterface.removeColumn('books', 'provider', { transaction })
await queryInterface.removeColumn('books', 'providerId', { transaction })
await transaction.commit()
} catch (err) {
await transaction.rollback()
throw err
}
}
}