disallow warnings on database and fix all lint warnings

This commit is contained in:
Ulf Gebhardt 2022-02-23 00:41:04 +01:00
parent b425124721
commit a896c9eb8c
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
25 changed files with 88 additions and 27 deletions

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* FIRST MIGRATION /* FIRST MIGRATION
* *
* This migration is special since it takes into account that * This migration is special since it takes into account that
@ -12,6 +9,9 @@
* databases. * databases.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// write upgrade logic as parameter of queryFn // write upgrade logic as parameter of queryFn
await queryFn(` await queryFn(`

View File

@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO ADD USER SETTINGS /* MIGRATION TO ADD USER SETTINGS
* *
* This migration adds the table `user_setting` in order to store all sorts of user configuration data * This migration adds the table `user_setting` in order to store all sorts of user configuration data
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(` await queryFn(`
CREATE TABLE IF NOT EXISTS \`user_setting\` ( CREATE TABLE IF NOT EXISTS \`user_setting\` (

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO CREATE THE LOGIN_SERVER TABLES /* MIGRATION TO CREATE THE LOGIN_SERVER TABLES
* *
* This migration creates the `login_server` tables in the `community_server` database (`gradido_community`). * This migration creates the `login_server` tables in the `community_server` database (`gradido_community`).
@ -8,6 +5,9 @@
* `0004-login_server_data` which will fill the tables with the existing data * `0004-login_server_data` which will fill the tables with the existing data
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(` await queryFn(`
CREATE TABLE IF NOT EXISTS \`login_app_access_tokens\` ( CREATE TABLE IF NOT EXISTS \`login_app_access_tokens\` (

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO COPY LOGIN_SERVER DATA /* MIGRATION TO COPY LOGIN_SERVER DATA
* *
* This migration copies all existing data from the `login_server` database (`gradido_login`) * This migration copies all existing data from the `login_server` database (`gradido_login`)
@ -12,6 +9,9 @@
* NOTE: This migration does not delete the data when downgrading! * NOTE: This migration does not delete the data when downgrading!
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
const LOGIN_SERVER_DB = 'gradido_login' const LOGIN_SERVER_DB = 'gradido_login'
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
@ -62,6 +62,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
`) `)
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// TODO NO EMPTY FUNCTION // EMPTY FUNCTION
} }

View File

@ -3,6 +3,9 @@
* This migration adds the table `login_pending_tasks_admin` to store pending creations * This migration adds the table `login_pending_tasks_admin` to store pending creations
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(` await queryFn(`
CREATE TABLE IF NOT EXISTS \`login_pending_tasks_admin\` ( CREATE TABLE IF NOT EXISTS \`login_pending_tasks_admin\` (

View File

@ -5,6 +5,9 @@
* to also explicitly define it in the table * to also explicitly define it in the table
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Explicitly change the charset and collate to the one used to then change it // Explicitly change the charset and collate to the one used to then change it
await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;') await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;')

View File

@ -6,10 +6,13 @@
* and dead entries * and dead entries
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('DELETE FROM `login_pending_tasks`;') await queryFn('DELETE FROM `login_pending_tasks`;')
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot undelete things // cannot undelete things
} }

View File

@ -6,6 +6,9 @@
* login_users. * login_users.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Fill in missing emails from login_users // Fill in missing emails from login_users
await queryFn( await queryFn(
@ -18,6 +21,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
await queryFn(`DELETE FROM state_users WHERE email = ''`) await queryFn(`DELETE FROM state_users WHERE email = ''`)
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot undelete things // cannot undelete things
} }

View File

@ -5,6 +5,9 @@
* account is set as not yet activated * account is set as not yet activated
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Generate a random private key where the required data is present (pubkey + password + passphrase). // Generate a random private key where the required data is present (pubkey + password + passphrase).
// Furthermore the email needs to be confirmed // Furthermore the email needs to be confirmed
@ -23,6 +26,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
) )
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot undelete things // cannot undelete things
} }

View File

@ -4,6 +4,9 @@
* Copy missing data from login_users to state_users. * Copy missing data from login_users to state_users.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Copy data with intact private key // Copy data with intact private key
await queryFn( await queryFn(
@ -40,6 +43,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
) )
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot undelete things // cannot undelete things
} }

View File

@ -5,6 +5,9 @@
* delete the right one of the duplicate keys * delete the right one of the duplicate keys
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Delete data with no reference in login_users table // Delete data with no reference in login_users table
await queryFn(`DELETE FROM login_user_backups WHERE user_id NOT IN (SELECT id FROM login_users)`) await queryFn(`DELETE FROM login_user_backups WHERE user_id NOT IN (SELECT id FROM login_users)`)
@ -13,6 +16,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
await queryFn(`DELETE FROM login_user_backups WHERE id IN (21, 103, 313, 325, 726, 750, 1098)`) await queryFn(`DELETE FROM login_user_backups WHERE id IN (21, 103, 313, 325, 726, 750, 1098)`)
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot undelete things // cannot undelete things
} }

View File

@ -4,6 +4,10 @@
* we need to detect which word list was used and transform it accordingly. * we need to detect which word list was used and transform it accordingly.
* This also removes the trailing space * This also removes the trailing space
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
@ -62,6 +66,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
}) })
} }
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
return [] // cannot transform things back // cannot transform things back
} }

View File

@ -5,6 +5,9 @@
* The migration reduces the amount of tables to 28 * The migration reduces the amount of tables to 28
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`DROP TABLE \`login_app_access_tokens\`;`) await queryFn(`DROP TABLE \`login_app_access_tokens\`;`)
await queryFn(`DROP TABLE \`pending_transactions\`;`) await queryFn(`DROP TABLE \`pending_transactions\`;`)

View File

@ -5,6 +5,9 @@
* The migration reduces the amount of tables to 16 * The migration reduces the amount of tables to 16
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`DROP TABLE \`address_types\`;`) await queryFn(`DROP TABLE \`address_types\`;`)
await queryFn(`DROP TABLE \`admin_errors\`;`) await queryFn(`DROP TABLE \`admin_errors\`;`)

View File

@ -7,6 +7,9 @@
* the new table to properly describe what it does * the new table to properly describe what it does
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// drop duplicate table, it was unused // drop duplicate table, it was unused
await queryFn('DROP TABLE `login_pending_tasks`;') await queryFn('DROP TABLE `login_pending_tasks`;')

View File

@ -4,6 +4,9 @@
* combines its data with transaction_signatures. * combines its data with transaction_signatures.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Drop column `state_group_id` since it only contains "0" as value, no variation. // Drop column `state_group_id` since it only contains "0" as value, no variation.
// Furthermore it was not present in our model itself (meaning that newly created ) // Furthermore it was not present in our model itself (meaning that newly created )

View File

@ -4,6 +4,9 @@
* the `state_users` table, where the later is the target. * the `state_users` table, where the later is the target.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Drop column `group_id` since it contains uniform data which is not the same as the uniform data // Drop column `group_id` since it contains uniform data which is not the same as the uniform data
// on login_users. Since we do not need this data anyway, we sjust throw it away. // on login_users. Since we do not need this data anyway, we sjust throw it away.

View File

@ -4,6 +4,9 @@
* the `state_users` table, where the later is the target. * the `state_users` table, where the later is the target.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// We only keep the passphrase, the mnemonic type is a constant, // We only keep the passphrase, the mnemonic type is a constant,
// since every passphrase was converted to mnemonic type 2 // since every passphrase was converted to mnemonic type 2

View File

@ -5,6 +5,9 @@
* The table affected is `login_email_opt_in` * The table affected is `login_email_opt_in`
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Delete email opt in codes which can not be linked to an user // Delete email opt in codes which can not be linked to an user
await queryFn(` await queryFn(`

View File

@ -4,6 +4,9 @@
* and removes columns with no meaningful value * and removes columns with no meaningful value
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// rename `state_users` table to `users` // rename `state_users` table to `users`
await queryFn('RENAME TABLE `state_users` TO `users`;') await queryFn('RENAME TABLE `state_users` TO `users`;')

View File

@ -4,6 +4,9 @@
* `publisher_id`, `order_id`. `product_id`. * `publisher_id`, `order_id`. `product_id`.
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn( await queryFn(
'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `affiliate_program_id` int(11) DEFAULT NULL;', 'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `affiliate_program_id` int(11) DEFAULT NULL;',

View File

@ -4,6 +4,9 @@
* we can delete it from the database * we can delete it from the database
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Remove transactions with type 9 (start decay block). This should affect exactly 1 row // Remove transactions with type 9 (start decay block). This should affect exactly 1 row
await queryFn(`DELETE FROM transactions WHERE transaction_type_id = 9;`) await queryFn(`DELETE FROM transactions WHERE transaction_type_id = 9;`)

View File

@ -4,6 +4,9 @@
* a date as it is standard for soft delete fields * a date as it is standard for soft delete fields
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Create new `deletedAt` column // Create new `deletedAt` column
await queryFn( await queryFn(

View File

@ -3,6 +3,9 @@
* Combine all transaction tables into one table with all data * Combine all transaction tables into one table with all data
*/ */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Create new `user_id` column (former `state_user_id`), with a temporary default of null // Create new `user_id` column (former `state_user_id`), with a temporary default of null
await queryFn( await queryFn(

View File

@ -16,7 +16,7 @@
"dev_up": "ts-node src/index.ts up", "dev_up": "ts-node src/index.ts up",
"dev_down": "ts-node src/index.ts down", "dev_down": "ts-node src/index.ts down",
"dev_reset": "ts-node src/index.ts reset", "dev_reset": "ts-node src/index.ts reset",
"lint": "eslint . --ext .js,.ts", "lint": "eslint --max-warnings=0 --ext .js,.ts .",
"seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config", "seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config",
"seed": "ts-node src/index.ts seed" "seed": "ts-node src/index.ts seed"
}, },