From 84c0c6f10b7cc07083f6b4ea439035257a28f68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 May 2022 02:56:38 +0200 Subject: [PATCH 01/21] start creating contributionLinks table --- .../ContributionLinks.ts | 108 ++++++++++++++++++ database/entity/ContributionLinks.ts | 1 + 2 files changed, 109 insertions(+) create mode 100644 database/entity/0038-add_contribution_links_table/ContributionLinks.ts create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts new file mode 100644 index 000000000..5f78a7450 --- /dev/null +++ b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts @@ -0,0 +1,108 @@ +import Decimal from 'decimal.js-light' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' + +export enum CycleTypes { + ONCE = 1, + HOUR = 2, + TWOHOURS = 3, + FOURHOURS = 4, + EIGHTHOURS = 5, + HALFDAY = 6, + DAY = 7, + TWODAYS = 8, + THREEDAYS = 9, + FOURDAYS = 10, + FIVEDAYS = 11, + SIXDAYS = 12, + WEEK = 13, + TWOWEEKS = 14, + MONTH = 15, + TWOMONTH = 16, + QUARTER = 17, + HALFYEAR = 18, + YEAR = 19, +} + +@Entity('contribution_links') +export class ContributionLinks extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) + name: string + + @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) + description: string + + @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) + validFrom: Date | null + + @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) + validTo: Date | null + + @Column({ + type: 'decimal', + precision: 40, + scale: 20, + nullable: false, + transformer: DecimalTransformer, + }) + amount: Decimal + + @Column({ name: 'cycle', unsigned: true, nullable: false }) + cycle: number + + @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) + maxPerCycle: number + + @Column({ + name: 'max_amount_per_month', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAmountPerMonth: Decimal + + @Column({ + name: 'total_max_count_of_contribution', + unsigned: true, + nullable: true, + default: null, + }) + totalMaxCountOfContribution: number | null + + @Column({ + name: 'max_account_balance', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAccountBalance: Decimal + + @Column({ + name: 'min_gap_hours', + unsigned: true, + nullable: true, + default: null, + }) + minGapHours: number | null + + @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) + createdAt: Date | null + + @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + deletedAt: Date | null + + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string + + @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) + linkEnabled: boolean | null +} diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..721dfd2b3 --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' From 2444c94af9f6d3869e65721317ffd58a29a408a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 1 Jun 2022 01:19:44 +0200 Subject: [PATCH 02/21] create migration and entity for new contribution_links table --- .../ContributionLinks.ts | 2 +- database/entity/ContributionLinks.ts | 2 +- .../0037-add_contribution_links_table.ts | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) rename database/entity/{0038-add_contribution_links_table => 0037-add_contribution_links_table}/ContributionLinks.ts (97%) create mode 100644 database/migrations/0037-add_contribution_links_table.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts similarity index 97% rename from database/entity/0038-add_contribution_links_table/ContributionLinks.ts rename to database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 5f78a7450..2fb4e2801 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -100,7 +100,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) deletedAt: Date | null - @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts index 721dfd2b3..de26c1c4a 100644 --- a/database/entity/ContributionLinks.ts +++ b/database/entity/ContributionLinks.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts new file mode 100644 index 000000000..79bcdf5ce --- /dev/null +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -0,0 +1,35 @@ +/* MIGRATION TO ADD CONTRIBUTION_LINKS + * + * This migration adds the table `contribution_links` in order to store all sorts of contribution_links 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>) { + await queryFn(` + CREATE TABLE IF NOT EXISTS \`contribution_links\` ( + \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, + \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + \`valid_from\` datetime NULL, + \`valid_to\` datetime NULL, + \`amount\` bigint(20) NOT NULL, + \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, + \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, + \`max_account_balance\` bigint(20) NULL DEFAULT NULL, + \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, + \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + \`deleted_at\` datetime NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // write downgrade logic as parameter of queryFn + await queryFn(`DROP TABLE IF EXISTS \`contribution_links\`;`) +} From 74bcdaf8c4f11e3f2746c8d2f33e0b1bbd1d0a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 3 Jun 2022 00:06:14 +0200 Subject: [PATCH 03/21] add .project and correct .gitignore --- .gitignore | 2 -- .project | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .project diff --git a/.gitignore b/.gitignore index 08ccd2b30..6ac3a32c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.dbeaver -.project *.log /node_modules/* messages.pot diff --git a/.project b/.project new file mode 100644 index 000000000..5d9663f32 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + Gradido + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.jkiss.dbeaver.DBeaverNature + org.eclipse.wst.jsdt.core.jsNature + + From bb35332e2ed6c0bf66b3cd4ec29b82a679c97db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:13:27 +0200 Subject: [PATCH 04/21] change Cycle Type in tabel ContributionLinks --- .dbeaver/.credentials-config.json.bak | 2 ++ .dbeaver/.data-sources.json.bak | 33 +++++++++++++++++++ .dbeaver/credentials-config.json | 3 ++ .dbeaver/data-sources.json | 32 ++++++++++++++++++ .../ContributionLinks.ts | 26 ++------------- .../0037-add_contribution_links_table.ts | 2 +- 6 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 .dbeaver/.credentials-config.json.bak create mode 100644 .dbeaver/.data-sources.json.bak create mode 100644 .dbeaver/credentials-config.json create mode 100644 .dbeaver/data-sources.json diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak new file mode 100644 index 000000000..2eca1988d --- /dev/null +++ b/.dbeaver/.credentials-config.json.bak @@ -0,0 +1,2 @@ +'U[V$8%kQN, +`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak new file mode 100644 index 000000000..7d9528f01 --- /dev/null +++ b/.dbeaver/.data-sources.json.bak @@ -0,0 +1,33 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "database": "gradido", + "url": "jdbc:mariadb://localhost:3306/gradido", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/.dbeaver/credentials-config.json b/.dbeaver/credentials-config.json new file mode 100644 index 000000000..d814bdfcf --- /dev/null +++ b/.dbeaver/credentials-config.json @@ -0,0 +1,3 @@ +4k1,fbAqĬc##s8-1&;"7djM?bljfBq= +my +vV \ No newline at end of file diff --git a/.dbeaver/data-sources.json b/.dbeaver/data-sources.json new file mode 100644 index 000000000..096f0d57e --- /dev/null +++ b/.dbeaver/data-sources.json @@ -0,0 +1,32 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "url": "jdbc:mariadb://localhost:3306/", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 2fb4e2801..0626a5067 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -2,28 +2,6 @@ import Decimal from 'decimal.js-light' import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' -export enum CycleTypes { - ONCE = 1, - HOUR = 2, - TWOHOURS = 3, - FOURHOURS = 4, - EIGHTHOURS = 5, - HALFDAY = 6, - DAY = 7, - TWODAYS = 8, - THREEDAYS = 9, - FOURDAYS = 10, - FIVEDAYS = 11, - SIXDAYS = 12, - WEEK = 13, - TWOWEEKS = 14, - MONTH = 15, - TWOMONTH = 16, - QUARTER = 17, - HALFYEAR = 18, - YEAR = 19, -} - @Entity('contribution_links') export class ContributionLinks extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) @@ -50,8 +28,8 @@ export class ContributionLinks extends BaseEntity { }) amount: Decimal - @Column({ name: 'cycle', unsigned: true, nullable: false }) - cycle: number + @Column({ length: 12, nullable: false, collation: 'utf8mb4_unicode_ci' }) + cycle: string @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) maxPerCycle: number diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 79bcdf5ce..42f03184b 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From 698f13078e73472186f15651094674e3fef4ff58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:14:02 +0200 Subject: [PATCH 05/21] define enum for ContributionLinks cycles --- .../src/graphql/enum/ContributionCycleType.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts new file mode 100644 index 000000000..05084a669 --- /dev/null +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -0,0 +1,29 @@ +import { registerEnumType } from 'type-graphql' + +export enum ContributionCycleType { + NONE = 'none', + ONCE = 'once', + HOUR = 'hour', + TWO_HOURS = 'two_hours', + FOUR_HOURS = 'four_hours', + EIGHT_HOURS = 'eight_hours', + HALF_DAY = 'half_day', + DAY = 'day', + TWO_DAYS = 'two_days', + THREE_DAYS = 'three_days', + FOUR_DAYS = 'four_days', + FIVE_DAYS = 'five_days', + SIX_DAYS = 'six_days', + WEEK = 'week', + TWO_WEEKS = 'two_weeks', + MONTH = 'month', + TWO_MONTH = 'two_month', + QUARTER = 'quarter', + HALF_YEAR = 'half_year', + YEAR = 'year', +} + +registerEnumType(ContributionCycleType, { + name: 'ContributionCycleType', // this one is mandatory + description: 'Name of the Type of the ContributionCycle', // this one is optional +}) From e71725686c03c2e459081ef90ecd90db5205ffb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:21:40 +0200 Subject: [PATCH 06/21] change backend config for db-version 0037 --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 28318ed6b..ec469c183 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0036-unique_previous_in_transactions', + DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From a881103c5f70f0e67c394e447436085808309f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:52:08 +0200 Subject: [PATCH 07/21] add softdelete feature to contributionlinks --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 0626a5067..6539716c6 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -1,5 +1,5 @@ import Decimal from 'decimal.js-light' -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') @@ -75,7 +75,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) createdAt: Date | null - @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + @DeleteDateColumn() deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) From 605a6757a35f8600c7df8b311e075ea4a4b750ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:32:42 +0200 Subject: [PATCH 08/21] change default cycle-value to ONCE --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 42f03184b..5e55f4ff1 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From fd352602ec3ecbed5dcb15bbe9811a519df669fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:33:26 +0200 Subject: [PATCH 09/21] delete value NONE from enum --- backend/src/graphql/enum/ContributionCycleType.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts index 05084a669..5fe494a02 100644 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -1,7 +1,6 @@ import { registerEnumType } from 'type-graphql' export enum ContributionCycleType { - NONE = 'none', ONCE = 'once', HOUR = 'hour', TWO_HOURS = 'two_hours', From 114465c23490b985848f359d0f86e4f4935b8cc3 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:24:22 +0200 Subject: [PATCH 10/21] Update backend/src/config/index.ts Co-authored-by: Moriz Wahl --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index ec469c183..f4999c4a8 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', + DB_VERSION: '0037-add_contribution_links_table', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From b65aa5cefccbf315844c4820fd03f7b869362933 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:26:30 +0200 Subject: [PATCH 11/21] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 6539716c6..fde67eef3 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -72,8 +72,8 @@ export class ContributionLinks extends BaseEntity { }) minGapHours: number | null - @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) - createdAt: Date | null + @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) + createdAt: Date @DeleteDateColumn() deletedAt: Date | null From 83c66d052a969cab0c1af0a7ecc2823adf8ab8ec Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:27:54 +0200 Subject: [PATCH 12/21] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index fde67eef3..16500b06b 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -81,6 +81,6 @@ export class ContributionLinks extends BaseEntity { @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string - @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) - linkEnabled: boolean | null + @Column({ name: 'link_enabled', type: 'boolean', default: true }) + linkEnabled: boolean } From 3328c200d8d067d2e727495e6a727f65a6c791ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:28:56 +0200 Subject: [PATCH 13/21] rework PR comments --- .gitignore | 1 + database/migrations/0037-add_contribution_links_table.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ac3a32c2..ced6746aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +*.bak /node_modules/* messages.pot nbproject diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 5e55f4ff1..4d3527ef5 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -24,7 +24,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, - \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) } From e76817ebdbde036eaad068743d1edff60d704819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:55:52 +0200 Subject: [PATCH 14/21] column validFrom NOT NULL --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 4d3527ef5..e05bfd5e7 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -12,7 +12,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - \`valid_from\` datetime NULL, + \`valid_from\` datetime NOT NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', From 94a48173e0f023b5b1f371678572ef293e5ae52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:20:05 +0200 Subject: [PATCH 15/21] remove *.bak files from repo Merge remote-tracking branch 'origin/1920-feature-create-contribution-link-table' into 1920-feature-create-contribution-link-table --- .dbeaver/.credentials-config.json.bak | 2 -- .dbeaver/.data-sources.json.bak | 33 --------------------------- 2 files changed, 35 deletions(-) delete mode 100644 .dbeaver/.credentials-config.json.bak delete mode 100644 .dbeaver/.data-sources.json.bak diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak deleted file mode 100644 index 2eca1988d..000000000 --- a/.dbeaver/.credentials-config.json.bak +++ /dev/null @@ -1,2 +0,0 @@ -'U[V$8%kQN, -`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak deleted file mode 100644 index 7d9528f01..000000000 --- a/.dbeaver/.data-sources.json.bak +++ /dev/null @@ -1,33 +0,0 @@ -{ - "folders": {}, - "connections": { - "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { - "provider": "mysql", - "driver": "mariaDB", - "name": "gradido", - "save-password": true, - "read-only": false, - "configuration": { - "host": "localhost", - "port": "3306", - "database": "gradido", - "url": "jdbc:mariadb://localhost:3306/gradido", - "home": "mysql_client", - "type": "dev", - "auth-model": "native", - "handlers": {} - } - } - }, - "connection-types": { - "dev": { - "name": "Development", - "color": "255,255,255", - "description": "Regular development database", - "auto-commit": true, - "confirm-execute": false, - "confirm-data-change": false, - "auto-close-transactions": false - } - } -} \ No newline at end of file From d7ff6446d994735e1468b18979943099fd4ecc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:52:40 +0200 Subject: [PATCH 16/21] evaluate nullable columns vs entity --- .../ContributionLinks.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 16500b06b..7b391606f 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -11,10 +11,10 @@ export class ContributionLinks extends BaseEntity { name: string @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) - description: string + memo: string - @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) - validFrom: Date | null + @Column({ name: 'valid_from', type: 'datetime', nullable: false }) + validFrom: Date @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) validTo: Date | null @@ -43,7 +43,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAmountPerMonth: Decimal + maxAmountPerMonth: Decimal | null @Column({ name: 'total_max_count_of_contribution', @@ -62,7 +62,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAccountBalance: Decimal + maxAccountBalance: Decimal | null @Column({ name: 'min_gap_hours', @@ -79,7 +79,7 @@ export class ContributionLinks extends BaseEntity { deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string + code: string | null @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean From 8a0147c8117f38d23f3c02b29ff0bf81858370b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:54:06 +0200 Subject: [PATCH 17/21] shift enum in ticket #1921 --- .../src/graphql/enum/ContributionCycleType.ts | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts deleted file mode 100644 index 5fe494a02..000000000 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { registerEnumType } from 'type-graphql' - -export enum ContributionCycleType { - ONCE = 'once', - HOUR = 'hour', - TWO_HOURS = 'two_hours', - FOUR_HOURS = 'four_hours', - EIGHT_HOURS = 'eight_hours', - HALF_DAY = 'half_day', - DAY = 'day', - TWO_DAYS = 'two_days', - THREE_DAYS = 'three_days', - FOUR_DAYS = 'four_days', - FIVE_DAYS = 'five_days', - SIX_DAYS = 'six_days', - WEEK = 'week', - TWO_WEEKS = 'two_weeks', - MONTH = 'month', - TWO_MONTH = 'two_month', - QUARTER = 'quarter', - HALF_YEAR = 'half_year', - YEAR = 'year', -} - -registerEnumType(ContributionCycleType, { - name: 'ContributionCycleType', // this one is mandatory - description: 'Name of the Type of the ContributionCycle', // this one is optional -}) From 5121910c836dfe975a93487d1eaf181a43401245 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:03:15 +0200 Subject: [PATCH 18/21] rename ContributionLinks to ContributionLink, add CL entity to index --- .../0038-add_contribution_links_table/ContributionLink.ts | 2 +- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 + database/entity/index.ts | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 7b391606f..490ca3868 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -3,7 +3,7 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') -export class ContributionLinks extends BaseEntity { +export class ContributionLink extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) id: number diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index de26c1c4a..721dfd2b3 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..c7e4e2b7e --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/index.ts b/database/entity/index.ts index 46d9ef31a..991e482e9 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -1,3 +1,4 @@ +import { ContributionLink } from './ContributionLink' import { LoginElopageBuys } from './LoginElopageBuys' import { LoginEmailOptIn } from './LoginEmailOptIn' import { Migration } from './Migration' @@ -8,6 +9,7 @@ import { AdminPendingCreation } from './AdminPendingCreation' export const entities = [ AdminPendingCreation, + ContributionLink, LoginElopageBuys, LoginEmailOptIn, Migration, From 83c8f9731e87749de795968905b45287f3bb2981 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:05:13 +0200 Subject: [PATCH 19/21] remove duplicate file --- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index 721dfd2b3..c7e4e2b7e 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts deleted file mode 100644 index c7e4e2b7e..000000000 --- a/database/entity/ContributionLinks.ts +++ /dev/null @@ -1 +0,0 @@ -export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' From 795d3393981ccead3ab0b4645f0b6266e5e4dbee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:23:57 +0200 Subject: [PATCH 20/21] add type definitions, make code required (not null) --- .../0038-add_contribution_links_table/ContributionLink.ts | 8 +++++--- database/migrations/0038-add_contribution_links_table.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 490ca3868..496f57d71 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -47,6 +47,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'total_max_count_of_contribution', + type: 'int', unsigned: true, nullable: true, default: null, @@ -66,6 +67,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'min_gap_hours', + type: 'int', unsigned: true, nullable: true, default: null, @@ -75,11 +77,11 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) createdAt: Date - @DeleteDateColumn() + @DeleteDateColumn({ name: 'deleted_at' }) deletedAt: Date | null - @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string | null + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean diff --git a/database/migrations/0038-add_contribution_links_table.ts b/database/migrations/0038-add_contribution_links_table.ts index 3ac6821d6..f983644cc 100644 --- a/database/migrations/0038-add_contribution_links_table.ts +++ b/database/migrations/0038-add_contribution_links_table.ts @@ -23,7 +23,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, - \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL, \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) From a84f11880f3108d5cb2496a44b5576d78e51cdee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:31:40 +0200 Subject: [PATCH 21/21] rename migration 0037 to what it acutally does --- .../User.ts | 0 database/entity/User.ts | 2 +- ...rop_server_user_table.ts => 0037-drop_user_setting_table.ts} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename database/entity/{0037-drop_server_user_table => 0037-drop_user_setting_table}/User.ts (100%) rename database/migrations/{0037-drop_server_user_table.ts => 0037-drop_user_setting_table.ts} (100%) diff --git a/database/entity/0037-drop_server_user_table/User.ts b/database/entity/0037-drop_user_setting_table/User.ts similarity index 100% rename from database/entity/0037-drop_server_user_table/User.ts rename to database/entity/0037-drop_user_setting_table/User.ts diff --git a/database/entity/User.ts b/database/entity/User.ts index 6983f293b..2d434799e 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0037-drop_server_user_table/User' +export { User } from './0037-drop_user_setting_table/User' diff --git a/database/migrations/0037-drop_server_user_table.ts b/database/migrations/0037-drop_user_setting_table.ts similarity index 100% rename from database/migrations/0037-drop_server_user_table.ts rename to database/migrations/0037-drop_user_setting_table.ts