mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add server support for disabling limitations temporarily per category
This commit is contained in:
@@ -65,9 +65,14 @@ export interface CategoryAttributesVersion8 {
|
||||
extraTimeDay: number
|
||||
}
|
||||
|
||||
export interface CategoryAttributesVersion9 {
|
||||
disableLimitsUntil: string
|
||||
}
|
||||
|
||||
export type CategoryAttributes = CategoryAttributesVersion1 & CategoryAttributesVersion2 &
|
||||
CategoryAttributesVersion3 & CategoryAttributesVersion4 & CategoryAttributesVersion5 &
|
||||
CategoryAttributesVersion6 & CategoryAttributesVersion7 & CategoryAttributesVersion8
|
||||
CategoryAttributesVersion6 & CategoryAttributesVersion7 & CategoryAttributesVersion8 &
|
||||
CategoryAttributesVersion9
|
||||
|
||||
export type CategoryModel = Sequelize.Model & CategoryAttributes
|
||||
export type CategoryModelStatic = typeof Sequelize.Model & {
|
||||
@@ -187,6 +192,13 @@ export const attributesVersion8: SequelizeAttributes<CategoryAttributesVersion8>
|
||||
}
|
||||
}
|
||||
|
||||
export const attributesVersion9: SequelizeAttributes<CategoryAttributesVersion9> = {
|
||||
disableLimitsUntil: {
|
||||
...timestampColumn,
|
||||
defaultValue: 0
|
||||
}
|
||||
}
|
||||
|
||||
export const attributes: SequelizeAttributes<CategoryAttributes> = {
|
||||
...attributesVersion1,
|
||||
...attributesVersion2,
|
||||
@@ -195,7 +207,8 @@ export const attributes: SequelizeAttributes<CategoryAttributes> = {
|
||||
...attributesVersion5,
|
||||
...attributesVersion6,
|
||||
...attributesVersion7,
|
||||
...attributesVersion8
|
||||
...attributesVersion8,
|
||||
...attributesVersion9
|
||||
}
|
||||
|
||||
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 { attributesVersion9 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', 'disableLimitsUntil', {
|
||||
...categoryAttributes.disableLimitsUntil
|
||||
}, {
|
||||
transaction
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||
await sequelize.transaction({
|
||||
type: Transaction.TYPES.EXCLUSIVE
|
||||
}, async (transaction) => {
|
||||
await queryInterface.removeColumn('Categories', 'disableLimitsUntil', { transaction })
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user