Merge branch '1197-admin-interface-created-transactions-list' of https://github.com/gradido/gradido into 1197-admin-interface-created-transactions-list

This commit is contained in:
elweyn 2021-12-22 09:17:23 +01:00
commit 124e11e9d4
10 changed files with 127 additions and 43 deletions

View File

@ -29,7 +29,7 @@ import { elopageWebhook } from '../webhook/elopage'
// TODO implement // TODO implement
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
const DB_VERSION = '0005-admin_tables' const DB_VERSION = '0006-login_users_collation'
const createServer = async (context: any = serverContext): Promise<any> => { const createServer = async (context: any = serverContext): Promise<any> => {
// open mysql connection // open mysql connection

View File

@ -2,7 +2,7 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'ty
import { Balance } from '../Balance' import { Balance } from '../Balance'
// Moriz: I do not like the idea of having two user tables // Moriz: I do not like the idea of having two user tables
@Entity('state_users') @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
export class User extends BaseEntity { export class User extends BaseEntity {
@PrimaryGeneratedColumn('increment', { unsigned: true }) @PrimaryGeneratedColumn('increment', { unsigned: true })
id: number id: number
@ -16,16 +16,28 @@ export class User extends BaseEntity {
@Column({ type: 'binary', length: 32, name: 'public_key' }) @Column({ type: 'binary', length: 32, name: 'public_key' })
pubkey: Buffer pubkey: Buffer
@Column({ length: 255, nullable: true, default: null }) @Column({ length: 255, nullable: true, default: null, collation: 'utf8mb4_unicode_ci' })
email: string email: string
@Column({ name: 'first_name', length: 255, nullable: true, default: null }) @Column({
name: 'first_name',
length: 255,
nullable: true,
default: null,
collation: 'utf8mb4_unicode_ci',
})
firstName: string firstName: string
@Column({ name: 'last_name', length: 255, nullable: true, default: null }) @Column({
name: 'last_name',
length: 255,
nullable: true,
default: null,
collation: 'utf8mb4_unicode_ci',
})
lastName: string lastName: string
@Column({ length: 255, nullable: true, default: null }) @Column({ length: 255, nullable: true, default: null, collation: 'utf8mb4_unicode_ci' })
username: string username: string
@Column() @Column()

View File

@ -2,7 +2,7 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 't
import { UserSetting } from './UserSetting' import { UserSetting } from './UserSetting'
// Moriz: I do not like the idea of having two user tables // Moriz: I do not like the idea of having two user tables
@Entity('state_users') @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
export class User extends BaseEntity { export class User extends BaseEntity {
@PrimaryGeneratedColumn('increment', { unsigned: true }) @PrimaryGeneratedColumn('increment', { unsigned: true })
id: number id: number
@ -16,16 +16,28 @@ export class User extends BaseEntity {
@Column({ type: 'binary', length: 32, name: 'public_key' }) @Column({ type: 'binary', length: 32, name: 'public_key' })
pubkey: Buffer pubkey: Buffer
@Column({ length: 255, nullable: true, default: null }) @Column({ length: 255, nullable: true, default: null, collation: 'utf8mb4_unicode_ci' })
email: string email: string
@Column({ name: 'first_name', length: 255, nullable: true, default: null }) @Column({
name: 'first_name',
length: 255,
nullable: true,
default: null,
collation: 'utf8mb4_unicode_ci',
})
firstName: string firstName: string
@Column({ name: 'last_name', length: 255, nullable: true, default: null }) @Column({
name: 'last_name',
length: 255,
nullable: true,
default: null,
collation: 'utf8mb4_unicode_ci',
})
lastName: string lastName: string
@Column({ length: 255, nullable: true, default: null }) @Column({ length: 255, nullable: true, default: null, collation: 'utf8mb4_unicode_ci' })
username: string username: string
@Column() @Column()

View File

@ -0,0 +1,60 @@
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'typeorm'
import { LoginUserBackup } from '../LoginUserBackup'
// Moriz: I do not like the idea of having two user tables
@Entity('login_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
export class LoginUser extends BaseEntity {
@PrimaryGeneratedColumn('increment', { unsigned: true })
id: number
@Column({ length: 191, unique: true, collation: 'utf8mb4_unicode_ci' })
email: string
@Column({ name: 'first_name', length: 150, collation: 'utf8mb4_unicode_ci' })
firstName: string
@Column({ name: 'last_name', length: 255, default: '', collation: 'utf8mb4_unicode_ci' })
lastName: string
@Column({ length: 255, default: '', collation: 'utf8mb4_unicode_ci' })
username: string
@Column({ default: '', collation: 'utf8mb4_unicode_ci' })
description: string
@Column({ type: 'bigint', default: 0, unsigned: true })
password: BigInt
@Column({ name: 'pubkey', type: 'binary', length: 32, default: null, nullable: true })
pubKey: Buffer
@Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true })
privKey: Buffer
@Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true })
emailHash: Buffer
@Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP' })
createdAt: Date
@Column({ name: 'email_checked', default: 0 })
emailChecked: boolean
@Column({ name: 'passphrase_shown', default: 0 })
passphraseShown: boolean
@Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci' })
language: string
@Column({ default: 0 })
disabled: boolean
@Column({ name: 'group_id', default: 0, unsigned: true })
groupId: number
@Column({ name: 'publisher_id', default: 0 })
publisherId: number
@OneToOne(() => LoginUserBackup, (loginUserBackup) => loginUserBackup.loginUser)
loginUserBackup: LoginUserBackup
}

View File

@ -1 +1 @@
export { LoginUser } from './0003-login_server_tables/LoginUser' export { LoginUser } from './0006-login_users_collation/LoginUser'

View File

@ -1,15 +1,9 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* FIRST MIGRATION /* MIGRATION TO ADD USER SETTINGS
* *
* This migration is special since it takes into account that * This migration adds the table `user_setting` in order to store all sorts of user configuration data
* the database can be setup already but also may not be.
* Therefore you will find all `CREATE TABLE` statements with
* a `IF NOT EXISTS`, all `INSERT` with an `IGNORE` and in the
* downgrade function all `DROP TABLE` with a `IF EXISTS`.
* This ensures compatibility for existing or non-existing
* databases.
*/ */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {

View File

@ -1,15 +1,11 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* FIRST MIGRATION /* MIGRATION TO CREATE THE LOGIN_SERVER TABLES
* *
* This migration is special since it takes into account that * This migration creates the `login_server` tables in the `community_server` database (`gradido_community`).
* the database can be setup already but also may not be. * This is done to keep all data in the same place and is to be understood in conjunction with the next migration
* Therefore you will find all `CREATE TABLE` statements with * `0004-login_server_data` which will fill the tables with the existing data
* a `IF NOT EXISTS`, all `INSERT` with an `IGNORE` and in the
* downgrade function all `DROP TABLE` with a `IF EXISTS`.
* This ensures compatibility for existing or non-existing
* databases.
*/ */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {

View File

@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* FIRST MIGRATION /* MIGRATION TO COPY LOGIN_SERVER DATA
* *
* This migration is special since it takes into account that * This migration copies all existing data from the `login_server` database (`gradido_login`)
* the database can be setup already but also may not be. * to the `community_server` database (`gradido_community`) in case the login_server database
* Therefore you will find all `CREATE TABLE` statements with * is present.
* a `IF NOT EXISTS`, all `INSERT` with an `IGNORE` and in the *
* downgrade function all `DROP TABLE` with a `IF EXISTS`. * NOTE: This will fail if the two databases are located on different servers.
* This ensures compatibility for existing or non-existing * Manual export and import of the database will be required then.
* databases. * NOTE: This migration does not delete the data when downgrading!
*/ */
const LOGIN_SERVER_DB = 'gradido_login' const LOGIN_SERVER_DB = 'gradido_login'

View File

@ -1,12 +1,6 @@
/* MIGRATION FOR ADMIN INTERFACE /* MIGRATION FOR ADMIN INTERFACE
* *
* This migration is special since it takes into account that * This migration adds the table `login_pending_tasks_admin` to store pending creations
* the database can be setup already but also may not be.
* Therefore you will find all `CREATE TABLE` statements with
* a `IF NOT EXISTS`, all `INSERT` with an `IGNORE` and in the
* downgrade function all `DROP TABLE` with a `IF EXISTS`.
* This ensures compatibility for existing or non-existing
* databases.
*/ */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {

View File

@ -0,0 +1,16 @@
/* MIGRATION TO ALIGN COLLATIONS
*
* in oder to be able to compare `login_users` with `state_users`
* when the databases default is not `utf8mb4_unicode_ci`, we need
* to also explicitly define it in the table
*/
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(
'ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;',
)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8mb4;')
}