Add support for extra time for a specific day

This commit is contained in:
Jonas Lochmann
2020-03-02 01:00:00 +01:00
parent af17e6cc8e
commit 0ecb7e4830
10 changed files with 121 additions and 46 deletions
+18 -2
View File
@@ -61,9 +61,13 @@ export interface CategoryAttributesVersion7 {
sort: number
}
export interface CategoryAttributesVersion8 {
extraTimeDay: number
}
export type CategoryAttributes = CategoryAttributesVersion1 & CategoryAttributesVersion2 &
CategoryAttributesVersion3 & CategoryAttributesVersion4 & CategoryAttributesVersion5 &
CategoryAttributesVersion6 & CategoryAttributesVersion7
CategoryAttributesVersion6 & CategoryAttributesVersion7 & CategoryAttributesVersion8
export type CategoryModel = Sequelize.Model & CategoryAttributes
export type CategoryModelStatic = typeof Sequelize.Model & {
@@ -172,6 +176,17 @@ export const attributesVersion7: SequelizeAttributes<CategoryAttributesVersion7>
}
}
export const attributesVersion8: SequelizeAttributes<CategoryAttributesVersion8> = {
extraTimeDay: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: -1,
validate: {
min: -1
}
}
}
export const attributes: SequelizeAttributes<CategoryAttributes> = {
...attributesVersion1,
...attributesVersion2,
@@ -179,7 +194,8 @@ export const attributes: SequelizeAttributes<CategoryAttributes> = {
...attributesVersion4,
...attributesVersion5,
...attributesVersion6,
...attributesVersion7
...attributesVersion7,
...attributesVersion8
}
export const createCategoryModel = (sequelize: Sequelize.Sequelize): CategoryModelStatic => sequelize.define('Category', attributes) as CategoryModelStatic
@@ -0,0 +1,39 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion8 as categoryAttributes } from '../../category'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Categories', 'extraTimeDay', {
...categoryAttributes.extraTimeDay
}, {
transaction
})
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Categories', 'extraTimeDay', { transaction })
})
}