Add: unique constraint on bookseries table

This commit is contained in:
Nicholas Wallace 2024-09-14 11:44:19 -07:00
parent 8ae62da138
commit 868659a2f1

View File

@ -48,11 +48,16 @@ describe('migration-v2.13.5-series-column-unique', () => {
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false }
})
await queryInterface.createTable('BookSeries', {
// Create a table for BookSeries, with a unique constraint of bookId and seriesId
await queryInterface.createTable(
'BookSeries',
{
id: { type: Sequelize.UUID, primaryKey: true },
bookId: { type: Sequelize.UUID, allowNull: false },
seriesId: { type: Sequelize.UUID, allowNull: false }
})
},
{ uniqueKeys: { book_series_unique: { fields: ['bookId', 'seriesId'] } } }
)
// Set UUIDs for the tests
series1Id = 'fc086255-3fd2-4a95-8a28-840d9206501b'
series2Id = '70f46ac2-ee48-4b3c-9822-933cc15c29bd'
@ -199,11 +204,16 @@ describe('migration-v2.13.5-series-column-unique', () => {
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false }
})
await queryInterface.createTable('BookSeries', {
// Create a table for BookSeries, with a unique constraint of bookId and seriesId
await queryInterface.createTable(
'BookSeries',
{
id: { type: Sequelize.UUID, primaryKey: true },
bookId: { type: Sequelize.UUID, allowNull: false },
seriesId: { type: Sequelize.UUID, allowNull: false }
})
},
{ uniqueKeys: { book_series_unique: { fields: ['bookId', 'seriesId'] } } }
)
})
it('should not have unique constraint on series name and libraryId', async () => {
await up({ context: { queryInterface, logger: Logger } })