Update sequelize

This commit is contained in:
Jonas L
2019-06-24 00:00:00 +00:00
parent 17058c375c
commit e70a80bf46
38 changed files with 238 additions and 220 deletions
+5 -3
View File
@@ -26,8 +26,10 @@ export interface AddDeviceTokenAttributes {
createdAt: string
}
export type AddDeviceTokenInstance = Sequelize.Instance<AddDeviceTokenAttributes> & AddDeviceTokenAttributes
export type AddDeviceTokenModel = Sequelize.Model<AddDeviceTokenInstance, AddDeviceTokenAttributes>
export type AddDeviceTokenModel = Sequelize.Model & AddDeviceTokenAttributes
export type AddDeviceTokenModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): AddDeviceTokenModel;
}
export const attributes: SequelizeAttributes<AddDeviceTokenAttributes> = {
token: {
@@ -39,4 +41,4 @@ export const attributes: SequelizeAttributes<AddDeviceTokenAttributes> = {
createdAt: { ...timestampColumn }
}
export const createAddDeviceTokenModel = (sequelize: Sequelize.Sequelize): AddDeviceTokenModel => sequelize.define<AddDeviceTokenInstance, AddDeviceTokenInstance>('AddDeviceToken', attributes)
export const createAddDeviceTokenModel = (sequelize: Sequelize.Sequelize): AddDeviceTokenModelStatic => <AddDeviceTokenModelStatic>sequelize.define('AddDeviceToken', attributes)
+5 -3
View File
@@ -29,8 +29,10 @@ export interface AppAttributes {
recommendation: AppRecommendation
}
export type AppInstance = Sequelize.Instance<AppAttributes> & AppAttributes
export type AppModel = Sequelize.Model<AppInstance, AppAttributes>
export type AppModel = Sequelize.Model & AppAttributes
export type AppModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): AppModel;
}
export const attributes: SequelizeAttributes<AppAttributes> = {
familyId: {
@@ -54,4 +56,4 @@ export const attributes: SequelizeAttributes<AppAttributes> = {
recommendation: createEnumColumn(appRecommendationValues)
}
export const createAppModel = (sequelize: Sequelize.Sequelize): AppModel => sequelize.define<AppInstance, AppAttributes>('App', attributes)
export const createAppModel = (sequelize: Sequelize.Sequelize): AppModelStatic => <AppModelStatic>sequelize.define('App', attributes)
+5 -3
View File
@@ -27,8 +27,10 @@ export interface AppActivityAttributes {
title: string
}
export type AppActivityInstance = Sequelize.Instance<AppActivityAttributes> & AppActivityAttributes
export type AppActivityModel = Sequelize.Model<AppActivityInstance, AppActivityAttributes>
export type AppActivityModel = Sequelize.Model & AppActivityAttributes
export type AppActivityModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): AppActivityModel;
}
export const attributes: SequelizeAttributes<AppActivityAttributes> = {
familyId: {
@@ -58,4 +60,4 @@ export const attributes: SequelizeAttributes<AppActivityAttributes> = {
title: { ...optionalLabelColumn }
}
export const createAppActivityModel = (sequelize: Sequelize.Sequelize): AppActivityModel => sequelize.define<AppActivityInstance, AppActivityAttributes>('AppActivity', attributes)
export const createAppActivityModel = (sequelize: Sequelize.Sequelize): AppActivityModelStatic => <AppActivityModelStatic>sequelize.define('AppActivity', attributes)
+5 -3
View File
@@ -25,8 +25,10 @@ export interface AuthTokenAttributes {
createdAt: string
}
export type AuthTokenInstance = Sequelize.Instance<AuthTokenAttributes> & AuthTokenAttributes
export type AuthTokenModel = Sequelize.Model<AuthTokenInstance, AuthTokenAttributes>
export type AuthTokenModel = Sequelize.Model & AuthTokenAttributes
export type AuthTokenModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): AuthTokenModel;
}
export const attributes: SequelizeAttributes<AuthTokenAttributes> = {
token: {
@@ -43,4 +45,4 @@ export const attributes: SequelizeAttributes<AuthTokenAttributes> = {
createdAt: { ...timestampColumn }
}
export const createAuthtokenModel = (sequelize: Sequelize.Sequelize): AuthTokenModel => sequelize.define<AuthTokenInstance, AuthTokenAttributes>('AuthToken', attributes)
export const createAuthtokenModel = (sequelize: Sequelize.Sequelize): AuthTokenModelStatic => <AuthTokenModelStatic>sequelize.define('AuthToken', attributes)
+5 -3
View File
@@ -51,8 +51,10 @@ export interface CategoryAttributesVersion4 {
export type CategoryAttributes = CategoryAttributesVersion1 & CategoryAttributesVersion2 &
CategoryAttributesVersion3 & CategoryAttributesVersion4
export type CategoryInstance = Sequelize.Instance<CategoryAttributes> & CategoryAttributes
export type CategoryModel = Sequelize.Model<CategoryInstance, CategoryAttributes>
export type CategoryModel = Sequelize.Model & CategoryAttributes
export type CategoryModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): CategoryModel;
}
export const attributesVersion1: SequelizeAttributes<CategoryAttributesVersion1> = {
familyId: {
@@ -124,4 +126,4 @@ export const attributes: SequelizeAttributes<CategoryAttributes> = {
...attributesVersion4
}
export const createCategoryModel = (sequelize: Sequelize.Sequelize): CategoryModel => sequelize.define<CategoryInstance, CategoryAttributes>('Category', attributes)
export const createCategoryModel = (sequelize: Sequelize.Sequelize): CategoryModelStatic => <CategoryModelStatic>sequelize.define('Category', attributes)
+5 -3
View File
@@ -25,8 +25,10 @@ export interface CategoryAppAttributes {
packageName: string
}
export type CategoryAppInstance = Sequelize.Instance<CategoryAppAttributes> & CategoryAppAttributes
export type CategoryAppModel = Sequelize.Model<CategoryAppInstance, CategoryAppAttributes>
export type CategoryAppModel = Sequelize.Model & CategoryAppAttributes
export type CategoryAppModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): CategoryAppModel;
}
export const attributes: SequelizeAttributes<CategoryAppAttributes> = {
familyId: {
@@ -47,4 +49,4 @@ export const attributes: SequelizeAttributes<CategoryAppAttributes> = {
}
}
export const createCategoryAppModel = (sequelize: Sequelize.Sequelize): CategoryAppModel => sequelize.define<CategoryAppInstance, CategoryAppAttributes>('CategoryApp', attributes)
export const createCategoryAppModel = (sequelize: Sequelize.Sequelize): CategoryAppModelStatic => <CategoryAppModelStatic>sequelize.define('CategoryApp', attributes)
+10 -10
View File
@@ -17,7 +17,7 @@
import * as Sequelize from 'sequelize'
export const familyIdColumn: Sequelize.DefineAttributeColumnOptions = {
export const familyIdColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING(10),
allowNull: false,
validate: {
@@ -26,7 +26,7 @@ export const familyIdColumn: Sequelize.DefineAttributeColumnOptions = {
}
}
export const idWithinFamilyColumn: Sequelize.DefineAttributeColumnOptions = {
export const idWithinFamilyColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING(6),
allowNull: false,
validate: {
@@ -35,7 +35,7 @@ export const idWithinFamilyColumn: Sequelize.DefineAttributeColumnOptions = {
}
}
export const optionalIdWithinFamilyColumn: Sequelize.DefineAttributeColumnOptions = {
export const optionalIdWithinFamilyColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING(6),
allowNull: false,
validate: {
@@ -43,7 +43,7 @@ export const optionalIdWithinFamilyColumn: Sequelize.DefineAttributeColumnOption
}
}
export const versionColumn: Sequelize.DefineAttributeColumnOptions = {
export const versionColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING(4),
allowNull: false,
validate: {
@@ -51,7 +51,7 @@ export const versionColumn: Sequelize.DefineAttributeColumnOptions = {
is: /^[a-zA-Z0-9]{4}$/
}
}
export const labelColumn: Sequelize.DefineAttributeColumnOptions = {
export const labelColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING,
allowNull: false,
validate: {
@@ -59,12 +59,12 @@ export const labelColumn: Sequelize.DefineAttributeColumnOptions = {
}
}
export const optionalLabelColumn: Sequelize.DefineAttributeColumnOptions = {
export const optionalLabelColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING,
allowNull: false
}
export const createEnumColumn = (possibleValues: Array<string>): Sequelize.DefineAttributeColumnOptions => ({
export const createEnumColumn = (possibleValues: Array<string>): Sequelize.ModelAttributeColumnOptions => ({
type: Sequelize.STRING,
allowNull: false,
validate: {
@@ -74,7 +74,7 @@ export const createEnumColumn = (possibleValues: Array<string>): Sequelize.Defin
})
// warning: this results in an string field
export const timestampColumn: Sequelize.DefineAttributeColumnOptions = {
export const timestampColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.BIGINT,
allowNull: false,
validate: {
@@ -82,12 +82,12 @@ export const timestampColumn: Sequelize.DefineAttributeColumnOptions = {
}
}
export const booleanColumn: Sequelize.DefineAttributeColumnOptions = {
export const booleanColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.BOOLEAN,
allowNull: false
}
export const authTokenColumn: Sequelize.DefineAttributeColumnOptions = {
export const authTokenColumn: Sequelize.ModelAttributeColumnOptions = {
type: Sequelize.STRING(32),
allowNull: false,
validate: {
+5 -3
View File
@@ -23,8 +23,10 @@ export interface ConfigAttributes {
value: string | null
}
export type ConfigInstance = Sequelize.Instance<ConfigAttributes> & ConfigAttributes
export type ConfigModel = Sequelize.Model<ConfigInstance, ConfigAttributes>
export type ConfigModel = Sequelize.Model & ConfigAttributes
export type ConfigModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): ConfigModel;
}
export const attributes: SequelizeAttributes<ConfigAttributes> = {
id: {
@@ -41,7 +43,7 @@ export const attributes: SequelizeAttributes<ConfigAttributes> = {
}
}
export const createConfigModel = (sequelize: Sequelize.Sequelize): ConfigModel => sequelize.define<ConfigInstance, ConfigAttributes>('Config', attributes)
export const createConfigModel = (sequelize: Sequelize.Sequelize): ConfigModelStatic => <ConfigModelStatic>sequelize.define('Config', attributes)
export const configItemIds = {
statusMessage: 'status_message'
+5 -3
View File
@@ -93,8 +93,10 @@ export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersio
DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8 &
DeviceAttributesVersion9 & DeviceAttributesVersion10
export type DeviceInstance = Sequelize.Instance<DeviceAttributes> & DeviceAttributes
export type DeviceModel = Sequelize.Model<DeviceInstance, DeviceAttributes>
export type DeviceModel = Sequelize.Model & DeviceAttributes
export type DeviceModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): DeviceModel;
}
export const attributesVersion1: SequelizeAttributes<DeviceAttributesVersion1> = {
familyId: {
@@ -244,7 +246,7 @@ export const attributes: SequelizeAttributes<DeviceAttributes> = {
...attributesVersion10
}
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModel => sequelize.define<DeviceInstance, DeviceAttributes>('Device', attributes)
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModelStatic => <DeviceModelStatic>sequelize.define('Device', attributes)
export const hasDeviceManipulation = (device: DeviceAttributes) => {
const manipulationOfProtectionLevel = device.currentProtectionLevel !== device.highestProtectionLevel
const manipulationOfUsageStats = device.currentUsageStatsPermission !== device.highestUsageStatsPermission
+5 -3
View File
@@ -29,8 +29,10 @@ export interface FamilyAttributes {
hasFullVersion: boolean
}
export type FamilyInstance = Sequelize.Instance<FamilyAttributes> & FamilyAttributes
export type FamilyModel = Sequelize.Model<FamilyInstance, FamilyAttributes>
export type FamilyModel = Sequelize.Model & FamilyAttributes
export type FamilyModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): FamilyModel;
}
export const attributes: SequelizeAttributes<FamilyAttributes> = {
familyId: {
@@ -45,4 +47,4 @@ export const attributes: SequelizeAttributes<FamilyAttributes> = {
hasFullVersion: { ...booleanColumn }
}
export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModel => sequelize.define<FamilyInstance, FamilyAttributes>('Family', attributes)
export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModelStatic => <FamilyModelStatic>sequelize.define('Family', attributes)
+31 -32
View File
@@ -16,39 +16,39 @@
*/
import * as Sequelize from 'sequelize'
import { AddDeviceTokenModel, createAddDeviceTokenModel } from './adddevicetoken'
import { AppModel, createAppModel } from './app'
import { AppActivityModel, createAppActivityModel } from './appactivity'
import { AuthTokenModel, createAuthtokenModel } from './authtoken'
import { CategoryModel, createCategoryModel } from './category'
import { CategoryAppModel, createCategoryAppModel } from './categoryapp'
import { ConfigModel, createConfigModel } from './config'
import { createDeviceModel, DeviceModel } from './device'
import { createFamilyModel, FamilyModel } from './family'
import { createMailLoginTokenModel, MailLoginTokenModel } from './maillogintoken'
import { AddDeviceTokenModelStatic, createAddDeviceTokenModel } from './adddevicetoken'
import { AppModelStatic, createAppModel } from './app'
import { AppActivityModelStatic, createAppActivityModel } from './appactivity'
import { AuthTokenModelStatic, createAuthtokenModel } from './authtoken'
import { CategoryModelStatic, createCategoryModel } from './category'
import { CategoryAppModelStatic, createCategoryAppModel } from './categoryapp'
import { ConfigModelStatic, createConfigModel } from './config'
import { createDeviceModel, DeviceModelStatic } from './device'
import { createFamilyModel, FamilyModelStatic } from './family'
import { createMailLoginTokenModel, MailLoginTokenModelStatic } from './maillogintoken'
import { createUmzug } from './migration/umzug'
import { createOldDeviceModel, OldDeviceModel } from './olddevice'
import { createPurchaseModel, PurchaseModel } from './purchase'
import { createTimelimitRuleModel, TimelimitRuleModel } from './timelimitrule'
import { createUsedTimeModel, UsedTimeModel } from './usedtime'
import { createUserModel, UserModel } from './user'
import { createOldDeviceModel, OldDeviceModelStatic } from './olddevice'
import { createPurchaseModel, PurchaseModelStatic } from './purchase'
import { createTimelimitRuleModel, TimelimitRuleModelStatic } from './timelimitrule'
import { createUsedTimeModel, UsedTimeModelStatic } from './usedtime'
import { createUserModel, UserModelStatic } from './user'
export interface Database {
addDeviceToken: AddDeviceTokenModel
authtoken: AuthTokenModel
app: AppModel
appActivity: AppActivityModel
category: CategoryModel
categoryApp: CategoryAppModel
config: ConfigModel
device: DeviceModel
family: FamilyModel
mailLoginToken: MailLoginTokenModel
oldDevice: OldDeviceModel
purchase: PurchaseModel
timelimitRule: TimelimitRuleModel
usedTime: UsedTimeModel
user: UserModel
addDeviceToken: AddDeviceTokenModelStatic
authtoken: AuthTokenModelStatic
app: AppModelStatic
appActivity: AppActivityModelStatic
category: CategoryModelStatic
categoryApp: CategoryAppModelStatic
config: ConfigModelStatic
device: DeviceModelStatic
family: FamilyModelStatic
mailLoginToken: MailLoginTokenModelStatic
oldDevice: OldDeviceModelStatic
purchase: PurchaseModelStatic
timelimitRule: TimelimitRuleModelStatic
usedTime: UsedTimeModelStatic
user: UserModelStatic
transaction: <T> (autoCallback: (t: Sequelize.Transaction) => Promise<T>) => Promise<T>
}
@@ -73,11 +73,10 @@ const createDatabase = (sequelize: Sequelize.Sequelize): Database => ({
}, autoCallback) as any) as Promise<T>
})
export const sequelize = new Sequelize(process.env.DATABASE_URL || 'sqlite://test.db', {
export const sequelize = new Sequelize.Sequelize(process.env.DATABASE_URL || 'sqlite://test.db', {
define: {
timestamps: false
},
operatorsAliases: false,
logging: false
})
+5 -3
View File
@@ -27,8 +27,10 @@ export interface MailLoginTokenAttributes {
remainingAttempts: number
}
export type MailLoginTokenInstance = Sequelize.Instance<MailLoginTokenAttributes> & MailLoginTokenAttributes
export type MailLoginTokenModel = Sequelize.Model<MailLoginTokenInstance, MailLoginTokenAttributes>
export type MailLoginTokenModel = Sequelize.Model & MailLoginTokenAttributes
export type MailLoginTokenModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): MailLoginTokenModel;
}
export const attributes: SequelizeAttributes<MailLoginTokenAttributes> = {
mailLoginToken: {
@@ -59,4 +61,4 @@ export const attributes: SequelizeAttributes<MailLoginTokenAttributes> = {
}
}
export const createMailLoginTokenModel = (sequelize: Sequelize.Sequelize): MailLoginTokenModel => sequelize.define<MailLoginTokenInstance, MailLoginTokenAttributes>('MailLoginToken', attributes)
export const createMailLoginTokenModel = (sequelize: Sequelize.Sequelize): MailLoginTokenModelStatic => <MailLoginTokenModelStatic>sequelize.define('MailLoginToken', attributes)
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributes as addDeviceTokenAttributes } from '../../adddevicetoken'
import { attributes as appAttributes } from '../../app'
import { attributes as authTokenAttributes } from '../../authtoken'
@@ -30,7 +30,7 @@ import { attributesVersion1 as userAttributes } from '../../user'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.createTable('AddDeviceTokens', addDeviceTokenAttributes, { transaction })
await queryInterface.createTable('Apps', appAttributes, { transaction })
@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion2 } from '../../device'
import { attributes as oldDeviceAttributes } from '../../olddevice'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'lastConnectivity', {
...attributesVersion2.lastConnectivity
@@ -47,7 +47,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'lastConnectivity', { transaction })
await queryInterface.removeColumn('Devices', 'notSeenForLongTime', { transaction })
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributes as mailLoginTokenAttributes } from '../../maillogintoken'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.createTable('MailLoginTokens', mailLoginTokenAttributes, { transaction })
})
@@ -28,7 +28,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.dropTable('MailLoginTokens', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion3 } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'isUserKeptSignedIn', {
...attributesVersion3.isUserKeptSignedIn
@@ -32,7 +32,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'isUserKeptSignedIn', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion2 } from '../../user'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Users', 'categoryForNotAssignedApps', {
...attributesVersion2.categoryForNotAssignedApps
@@ -32,7 +32,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Users', 'categoryForNotAssignedApps', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion2 } from '../../category'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Categories', 'parentCategoryId', {
...attributesVersion2.parentCategoryId
@@ -32,7 +32,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Categories', 'parentCategoryId', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion4 } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'showDeviceConnected', {
...attributesVersion4.showDeviceConnected
@@ -32,7 +32,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'showDeviceConnected', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion2 } from '../../usedtime'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('UsedTimes', 'lastUpdate', {
...attributesVersion2.lastUpdate
@@ -34,7 +34,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeIndex('UsedTimes', ['lastUpdate'], { transaction })
await queryInterface.removeColumn('UsedTimes', 'lastUpdate', { transaction })
@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion5 as deviceAttributes } from '../../device'
import { attributesVersion3 as userAttributes } from '../../user'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
// users
await queryInterface.addColumn('Users', 'relaxPrimaryDeviceRule', {
@@ -41,7 +41,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
// users
await queryInterface.removeColumn('Users', 'relaxPrimaryDeviceRule', { transaction })
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion6 } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'considerRebootManipulation', {
...attributesVersion6.considerRebootManipulation
@@ -38,7 +38,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'considerRebootManipulation', { transaction })
await queryInterface.removeColumn('Devices', 'didReboot', { transaction })
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion4 as userAttributes } from '../../user'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Users', 'mailNotificationFlags', {
...userAttributes.mailNotificationFlags
@@ -30,7 +30,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Users', 'mailNotificationFlags', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion3 as categoryAttributes } from '../../category'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Categories', 'blockAllNotifications', {
...categoryAttributes.blockAllNotifications
@@ -30,7 +30,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Categories', 'blockAllNotifications', { transaction })
})
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion7 } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'currentOverlayPermission', {
...attributesVersion7.currentOverlayPermission
@@ -38,7 +38,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'currentOverlayPermission', { transaction })
await queryInterface.removeColumn('Devices', 'highestOverlayPermission', { transaction })
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion8 } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'asEnabled', {
...attributesVersion8.asEnabled
@@ -38,7 +38,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'asEnabled', { transaction })
await queryInterface.removeColumn('Devices', 'wasAsEnabled', { transaction })
@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributes as appActivityAttributes } from '../../appactivity'
import { attributesVersion9 as deviceAttributes } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.createTable('AppActivities', appActivityAttributes, { transaction })
await queryInterface.addColumn('Devices', 'activityLevelBlocking', {
@@ -34,7 +34,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.dropTable('AppActivities', { transaction })
await queryInterface.removeColumn('Devices', 'activityLevelBlocking', { transaction })
@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributes as categoryAttributes } from '../../category'
import { attributesVersion10 as deviceAttributes } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'isQorLater', {
...deviceAttributes.isQorLater
@@ -39,7 +39,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'isQorLater', { transaction })
await queryInterface.removeColumn('Categories', 'timeWarningFlags', { transaction })
@@ -15,12 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize } from 'sequelize'
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributes as configAttributes } from '../../config'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.createTable('Configs', configAttributes, { transaction })
})
@@ -28,7 +28,7 @@ export async function up (queryInterface: QueryInterface, sequelize: Sequelize)
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: 'EXCLUSIVE'
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.dropTable('Configs', { transaction })
})
+5 -3
View File
@@ -23,8 +23,10 @@ export interface OldDeviceAttributes {
deviceAuthToken: string
}
export type OldDeviceInstance = Sequelize.Instance<OldDeviceAttributes> & OldDeviceAttributes
export type OldDeviceModel = Sequelize.Model<OldDeviceInstance, OldDeviceAttributes>
export type OldDeviceModel = Sequelize.Model & OldDeviceAttributes
export type OldDeviceModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): OldDeviceModel;
}
export const attributes: SequelizeAttributes<OldDeviceAttributes> = {
deviceAuthToken: {
@@ -33,4 +35,4 @@ export const attributes: SequelizeAttributes<OldDeviceAttributes> = {
}
}
export const createOldDeviceModel = (sequelize: Sequelize.Sequelize): OldDeviceModel => sequelize.define<OldDeviceInstance, OldDeviceAttributes>('OldDevice', attributes)
export const createOldDeviceModel = (sequelize: Sequelize.Sequelize): OldDeviceModelStatic => <OldDeviceModelStatic>sequelize.define('OldDevice', attributes)
+5 -3
View File
@@ -29,8 +29,10 @@ export interface PurchaseAttributes {
newFullVersionEndTime: string
}
export type PurchaseInstance = Sequelize.Instance<PurchaseAttributes> & PurchaseAttributes
export type PurchaseModel = Sequelize.Model<PurchaseInstance, PurchaseAttributes>
export type PurchaseModel = Sequelize.Model & PurchaseAttributes
export type PurchaseModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): PurchaseModel;
}
export const attributes: SequelizeAttributes<PurchaseAttributes> = {
familyId: { ...familyIdColumn },
@@ -48,4 +50,4 @@ export const attributes: SequelizeAttributes<PurchaseAttributes> = {
newFullVersionEndTime: timestampColumn
}
export const createPurchaseModel = (sequelize: Sequelize.Sequelize): PurchaseModel => sequelize.define<PurchaseInstance, PurchaseAttributes>('Purchase', attributes)
export const createPurchaseModel = (sequelize: Sequelize.Sequelize): PurchaseModelStatic => <PurchaseModelStatic>sequelize.define('Purchase', attributes)
+5 -3
View File
@@ -28,8 +28,10 @@ export interface TimelimitRuleAttributes {
maximumTimeInMillis: number
}
export type TimelimitRuleInstance = Sequelize.Instance<TimelimitRuleAttributes> & TimelimitRuleAttributes
export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleInstance, TimelimitRuleAttributes>
export type TimelimitRuleModel = Sequelize.Model & TimelimitRuleAttributes
export type TimelimitRuleModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): TimelimitRuleModel;
}
export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = {
familyId: {
@@ -59,4 +61,4 @@ export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = {
}
}
export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModel => sequelize.define<TimelimitRuleInstance, TimelimitRuleAttributes>('TimelimitRule', attributes)
export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => <TimelimitRuleModelStatic>sequelize.define('TimelimitRule', attributes)
+1 -1
View File
@@ -18,5 +18,5 @@
import * as Sequelize from 'sequelize'
export type SequelizeAttributes<T extends { [key: string]: any }> = {
[P in keyof T]: Sequelize.DefineAttributeColumnOptions;
[P in keyof T]: Sequelize.ModelAttributeColumnOptions;
}
+5 -3
View File
@@ -32,8 +32,10 @@ export interface UsedTimeAttributesVersion2 {
export type UsedTimeAttributes = UsedTimeAttributesVersion1 & UsedTimeAttributesVersion2
export type UsedTimeInstance = Sequelize.Instance<UsedTimeAttributes> & UsedTimeAttributes
export type UsedTimeModel = Sequelize.Model<UsedTimeInstance, UsedTimeAttributes>
export type UsedTimeModel = Sequelize.Model & UsedTimeAttributes
export type UsedTimeModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): UsedTimeModel;
}
export const attributesVersion1: SequelizeAttributes<UsedTimeAttributesVersion1> = {
familyId: {
@@ -73,4 +75,4 @@ export const attributes = {
...attributesVersion2
}
export const createUsedTimeModel = (sequelize: Sequelize.Sequelize): UsedTimeModel => sequelize.define<UsedTimeInstance, UsedTimeAttributes>('UsedTime', attributes)
export const createUsedTimeModel = (sequelize: Sequelize.Sequelize): UsedTimeModelStatic => <UsedTimeModelStatic>sequelize.define('UsedTime', attributes)
+5 -3
View File
@@ -52,8 +52,10 @@ export interface UserAttributesVersion4 {
export type UserAttributes = UserAttributesVersion1 & UserAttributesVersion2 &
UserAttributesVersion3 & UserAttributesVersion4
export type UserInstance = Sequelize.Instance<UserAttributes> & UserAttributes
export type UserModel = Sequelize.Model<UserInstance, UserAttributes>
export type UserModel = Sequelize.Model & UserAttributes
export type UserModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): UserModel;
}
export const attributesVersion1: SequelizeAttributes<UserAttributesVersion1> = {
familyId: {
@@ -128,4 +130,4 @@ export const attributes: SequelizeAttributes<UserAttributes> = {
...attributesVersion4
}
export const createUserModel = (sequelize: Sequelize.Sequelize): UserModel => sequelize.define<UserInstance, UserAttributes>('User', attributes)
export const createUserModel = (sequelize: Sequelize.Sequelize): UserModelStatic => <UserModelStatic>sequelize.define('User', attributes)