mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 02:41:35 +00:00
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
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
|
|
}
|
|
}
|
|
}
|