From 234ef31622fd7a3bd366438f1fa3ff7c195ef091 Mon Sep 17 00:00:00 2001 From: haloivanid Date: Tue, 29 Oct 2024 19:00:18 +0700 Subject: [PATCH] feat(note): add note mvp note is main feature of finote #3 --- server/.erd/erdiadb.json | 1267 +++++-- server/.erd/index.html | 3200 +++++++++++++---- server/.erd/mermaid.html | 154 +- .../entities/core/note-account.entity.ts | 21 + .../entities/core/note-item.entity.ts | 38 + .../entities/core/note-member.entity.ts | 21 + .../entities/core/note-transaction.entity.ts | 27 + .../databases/entities/core/note.entity.ts | 14 + .../migrations/1730203011356-note.ts | 69 + 9 files changed, 3786 insertions(+), 1025 deletions(-) create mode 100644 server/src/databases/entities/core/note-account.entity.ts create mode 100644 server/src/databases/entities/core/note-item.entity.ts create mode 100644 server/src/databases/entities/core/note-member.entity.ts create mode 100644 server/src/databases/entities/core/note-transaction.entity.ts create mode 100644 server/src/databases/entities/core/note.entity.ts create mode 100644 server/src/databases/migrations/1730203011356-note.ts diff --git a/server/.erd/erdiadb.json b/server/.erd/erdiadb.json index cc4ea85..e2cd78c 100644 --- a/server/.erd/erdiadb.json +++ b/server/.erd/erdiadb.json @@ -1,10 +1,32 @@ [ + { + "$kind": "entity", + "name": "Note", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "note", + "hasRelation": false + }, + { + "$kind": "entity", + "name": "NoteTransaction", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "note_transaction", + "hasRelation": true + }, { "$kind": "entity", "name": "User", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "user", @@ -13,9 +35,9 @@ { "$kind": "entity", "name": "Account", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "account", @@ -23,32 +45,292 @@ }, { "$kind": "entity", - "name": "AccountHistory", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "NoteItem", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", - "dbName": "account_history", + "entity": "note_item", + "dbName": "note_item", "hasRelation": true }, { "$kind": "entity", "name": "UserSession", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "user_session", "hasRelation": true }, + { + "$kind": "entity", + "name": "AccountHistory", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "account_history", + "hasRelation": true + }, + { + "$kind": "entity", + "name": "NoteAccount", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "note_account", + "hasRelation": true + }, + { + "$kind": "entity", + "name": "NoteMember", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "note_member", + "hasRelation": true + }, + { + "$kind": "column", + "name": "id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "id", + "attributeKey": [ + "PK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 20481017.22 + }, + { + "$kind": "column", + "name": "created_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "created_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022023.08 + }, + { + "$kind": "column", + "name": "updated_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "updated_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022005.1 + }, + { + "$kind": "column", + "name": "name", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "name", + "attributeKey": [], + "isNullable": "", + "columnType": "*varchar", + "charset": "", + "columnTypeWithLength": "*varchar", + "comment": "", + "weight": 785012.25 + }, + { + "$kind": "column", + "name": "description", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "description", + "attributeKey": [], + "isNullable": "nullable", + "columnType": "varchar", + "charset": "", + "columnTypeWithLength": "varchar(100)", + "comment": "", + "weight": 743022.21 + }, + { + "$kind": "column", + "name": "id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "id", + "attributeKey": [ + "PK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 20481017.22 + }, + { + "$kind": "column", + "name": "created_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "created_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022023.08 + }, + { + "$kind": "column", + "name": "updated_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "updated_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022005.1 + }, + { + "$kind": "column", + "name": "note_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "note_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481012.11 + }, + { + "$kind": "column", + "name": "description", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "description", + "attributeKey": [], + "isNullable": "", + "columnType": "*varchar", + "charset": "", + "columnTypeWithLength": "*varchar(100)", + "comment": "", + "weight": 785022.21 + }, + { + "$kind": "column", + "name": "total", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "total", + "attributeKey": [], + "isNullable": "", + "columnType": "*numeric", + "charset": "", + "columnTypeWithLength": "*numeric", + "comment": "", + "weight": 797006.11 + }, + { + "$kind": "column", + "name": "pre_balance", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "pre_balance", + "attributeKey": [], + "isNullable": "", + "columnType": "*numeric", + "charset": "", + "columnTypeWithLength": "*numeric", + "comment": "", + "weight": 797010.08 + }, + { + "$kind": "column", + "name": "post_balance", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_transaction", + "dbName": "post_balance", + "attributeKey": [], + "isNullable": "", + "columnType": "*numeric", + "charset": "", + "columnTypeWithLength": "*numeric", + "comment": "", + "weight": 797010.11 + }, { "$kind": "column", "name": "id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "id", @@ -65,9 +347,9 @@ { "$kind": "column", "name": "created_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "created_at", @@ -82,9 +364,9 @@ { "$kind": "column", "name": "updated_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "updated_at", @@ -99,9 +381,9 @@ { "$kind": "column", "name": "email", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "email", @@ -116,9 +398,9 @@ { "$kind": "column", "name": "username", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "username", @@ -133,9 +415,9 @@ { "$kind": "column", "name": "password", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "password", @@ -150,9 +432,9 @@ { "$kind": "column", "name": "otp_type", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "otp_type", @@ -167,9 +449,9 @@ { "$kind": "column", "name": "otp", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "otp", @@ -184,9 +466,9 @@ { "$kind": "column", "name": "otp_expires_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "otp_expires_at", @@ -201,9 +483,9 @@ { "$kind": "column", "name": "id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "id", @@ -220,9 +502,9 @@ { "$kind": "column", "name": "created_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "created_at", @@ -237,9 +519,9 @@ { "$kind": "column", "name": "updated_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "updated_at", @@ -254,9 +536,9 @@ { "$kind": "column", "name": "user_id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "user_id", @@ -273,9 +555,9 @@ { "$kind": "column", "name": "type", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "type", @@ -290,9 +572,9 @@ { "$kind": "column", "name": "currency", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "currency", @@ -307,9 +589,9 @@ { "$kind": "column", "name": "name", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "name", @@ -324,9 +606,9 @@ { "$kind": "column", "name": "reference", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "reference", @@ -341,9 +623,9 @@ { "$kind": "column", "name": "balance", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "balance", @@ -358,9 +640,9 @@ { "$kind": "column", "name": "minimum_balance", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "minimum_balance", @@ -375,9 +657,9 @@ { "$kind": "column", "name": "version", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "version", @@ -392,11 +674,11 @@ { "$kind": "column", "name": "id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", + "entity": "note_item", "dbName": "id", "attributeKey": [ "PK" @@ -411,11 +693,11 @@ { "$kind": "column", "name": "created_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", + "entity": "note_item", "dbName": "created_at", "attributeKey": [], "isNullable": "", @@ -428,11 +710,11 @@ { "$kind": "column", "name": "updated_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", + "entity": "note_item", "dbName": "updated_at", "attributeKey": [], "isNullable": "", @@ -442,14 +724,33 @@ "comment": "", "weight": 1022005.1 }, + { + "$kind": "column", + "name": "transaction_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_item", + "dbName": "transaction_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481006.08 + }, { "$kind": "column", "name": "account_id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", + "entity": "note_item", "dbName": "account_id", "attributeKey": [ "FK" @@ -463,78 +764,80 @@ }, { "$kind": "column", - "name": "action", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "user_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", - "dbName": "action", - "attributeKey": [], + "entity": "note_item", + "dbName": "user_id", + "attributeKey": [ + "FK" + ], "isNullable": "", - "columnType": "*varchar", + "columnType": "*uuid", "charset": "", - "columnTypeWithLength": "*varchar", + "columnTypeWithLength": "*uuid", "comment": "", - "weight": 785025.23 + "weight": 10481005.07 }, { "$kind": "column", - "name": "description", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "name", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", - "dbName": "description", + "entity": "note_item", + "dbName": "name", "attributeKey": [], "isNullable": "", "columnType": "*varchar", "charset": "", - "columnTypeWithLength": "*varchar", + "columnTypeWithLength": "*varchar(100)", "comment": "", - "weight": 785022.21 + "weight": 785012.25 }, { "$kind": "column", - "name": "pre_balance", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "amount", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", - "dbName": "pre_balance", + "entity": "note_item", + "dbName": "amount", "attributeKey": [], "isNullable": "", "columnType": "*numeric", "charset": "", "columnTypeWithLength": "*numeric", "comment": "", - "weight": 797010.08 + "weight": 797025.13 }, { "$kind": "column", - "name": "post_balance", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "is_over_budget", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", - "entity": "account_history", - "dbName": "post_balance", + "entity": "note_item", + "dbName": "is_over_budget", "attributeKey": [], "isNullable": "", - "columnType": "*numeric", + "columnType": "*smallint", "charset": "", - "columnTypeWithLength": "*numeric", + "columnTypeWithLength": "*smallint", "comment": "", - "weight": 797010.11 + "weight": 910017.07 }, { "$kind": "column", "name": "id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "id", @@ -551,9 +854,9 @@ { "$kind": "column", "name": "created_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "created_at", @@ -568,9 +871,9 @@ { "$kind": "column", "name": "updated_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "updated_at", @@ -585,9 +888,9 @@ { "$kind": "column", "name": "user_id", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "user_id", @@ -604,9 +907,9 @@ { "$kind": "column", "name": "refresh_token", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "refresh_token", @@ -621,9 +924,9 @@ { "$kind": "column", "name": "refresh_token_expires_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "refresh_token_expires_at", @@ -638,9 +941,9 @@ { "$kind": "column", "name": "user_agent", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "user_agent", @@ -655,9 +958,9 @@ { "$kind": "column", "name": "ip_address", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "ip_address", @@ -672,9 +975,9 @@ { "$kind": "column", "name": "is_blocked", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "is_blocked", @@ -689,9 +992,9 @@ { "$kind": "column", "name": "attempt", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "attempt", @@ -706,9 +1009,9 @@ { "$kind": "column", "name": "access_token", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "access_token", @@ -723,9 +1026,9 @@ { "$kind": "column", "name": "access_token_expires_at", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "access_token_expires_at", @@ -740,9 +1043,9 @@ { "$kind": "column", "name": "is_verified", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "is_verified", @@ -757,9 +1060,9 @@ { "$kind": "column", "name": "last_login", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "last_login", @@ -772,14 +1075,358 @@ "weight": 980014.25 }, { - "name": "Account", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", - "$kind": "relation", - "entity": "account", - "dbName": "account", - "change": "none", + "$kind": "column", + "name": "id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "id", + "attributeKey": [ + "PK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 20481017.22 + }, + { + "$kind": "column", + "name": "created_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "created_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022023.08 + }, + { + "$kind": "column", + "name": "updated_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "updated_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022005.1 + }, + { + "$kind": "column", + "name": "account_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "account_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481025.23 + }, + { + "$kind": "column", + "name": "action", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "action", + "attributeKey": [], + "isNullable": "", + "columnType": "*varchar", + "charset": "", + "columnTypeWithLength": "*varchar", + "comment": "", + "weight": 785025.23 + }, + { + "$kind": "column", + "name": "description", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "description", + "attributeKey": [], + "isNullable": "", + "columnType": "*varchar", + "charset": "", + "columnTypeWithLength": "*varchar", + "comment": "", + "weight": 785022.21 + }, + { + "$kind": "column", + "name": "pre_balance", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "pre_balance", + "attributeKey": [], + "isNullable": "", + "columnType": "*numeric", + "charset": "", + "columnTypeWithLength": "*numeric", + "comment": "", + "weight": 797010.08 + }, + { + "$kind": "column", + "name": "post_balance", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "post_balance", + "attributeKey": [], + "isNullable": "", + "columnType": "*numeric", + "charset": "", + "columnTypeWithLength": "*numeric", + "comment": "", + "weight": 797010.11 + }, + { + "$kind": "column", + "name": "id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "id", + "attributeKey": [ + "PK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 20481017.22 + }, + { + "$kind": "column", + "name": "created_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "created_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022023.08 + }, + { + "$kind": "column", + "name": "updated_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "updated_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022005.1 + }, + { + "$kind": "column", + "name": "note_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "note_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481012.11 + }, + { + "$kind": "column", + "name": "account_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_account", + "dbName": "account_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481025.23 + }, + { + "$kind": "column", + "name": "id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "id", + "attributeKey": [ + "PK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 20481017.22 + }, + { + "$kind": "column", + "name": "created_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "created_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022023.08 + }, + { + "$kind": "column", + "name": "updated_at", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "updated_at", + "attributeKey": [], + "isNullable": "", + "columnType": "*timestamp", + "charset": "", + "columnTypeWithLength": "*timestamp", + "comment": "", + "weight": 1022005.1 + }, + { + "$kind": "column", + "name": "note_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "note_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481012.11 + }, + { + "$kind": "column", + "name": "user_id", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note_member", + "dbName": "user_id", + "attributeKey": [ + "FK" + ], + "isNullable": "", + "columnType": "*uuid", + "charset": "", + "columnTypeWithLength": "*uuid", + "comment": "", + "weight": 10481005.07 + }, + { + "name": "NoteTransaction", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_transaction", + "dbName": "note_transaction", + "change": "none", + "inverseEntityName": "Note", + "inverseEntityDBName": "note", + "joinColumnName": "note_id", + "joinPropertyName": "note_id", + "relationHash": "bm90ZTpub3RlX3RyYW5zYWN0aW9uOm9uZS10by1tYW55", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 2 + }, + { + "name": "Account", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "account", + "dbName": "account", + "change": "none", "inverseEntityName": "User", "inverseEntityDBName": "user", "joinColumnName": "user_id", @@ -794,19 +1441,41 @@ "order": 1 }, { - "name": "AccountHistory", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "name": "NoteItem", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "$kind": "relation", - "entity": "account_history", - "dbName": "account_history", + "entity": "note_item", + "dbName": "note_item", + "change": "none", + "inverseEntityName": "NoteTransaction", + "inverseEntityDBName": "note_transaction", + "joinColumnName": "transaction_id", + "joinPropertyName": "transaction_id", + "relationHash": "bm90ZV9pdGVtOm5vdGVfdHJhbnNhY3Rpb246b25lLXRvLW1hbnk=", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 1 + }, + { + "name": "NoteItem", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_item", + "dbName": "note_item", "change": "none", "inverseEntityName": "Account", "inverseEntityDBName": "account", "joinColumnName": "account_id", "joinPropertyName": "account_id", - "relationHash": "YWNjb3VudDphY2NvdW50X2hpc3Rvcnk6b25lLXRvLW1hbnk=", + "relationHash": "YWNjb3VudDpub3RlX2l0ZW06b25lLXRvLW1hbnk=", "joinColumnOne": false, "joinColumnNullable": true, "inverseJoinColumnNullable": false, @@ -815,11 +1484,33 @@ "isDuplicate": false, "order": 2 }, + { + "name": "NoteItem", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_item", + "dbName": "note_item", + "change": "none", + "inverseEntityName": "User", + "inverseEntityDBName": "user", + "joinColumnName": "user_id", + "joinPropertyName": "user_id", + "relationHash": "bm90ZV9pdGVtOnVzZXI6b25lLXRvLW1hbnk=", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 1 + }, { "name": "UserSession", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "$kind": "relation", "entity": "user_session", "dbName": "user_session", @@ -837,12 +1528,140 @@ "isDuplicate": false, "order": 2 }, + { + "name": "AccountHistory", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "account_history", + "dbName": "account_history", + "change": "none", + "inverseEntityName": "Account", + "inverseEntityDBName": "account", + "joinColumnName": "account_id", + "joinPropertyName": "account_id", + "relationHash": "YWNjb3VudDphY2NvdW50X2hpc3Rvcnk6b25lLXRvLW1hbnk=", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 2 + }, + { + "name": "NoteAccount", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_account", + "dbName": "note_account", + "change": "none", + "inverseEntityName": "Note", + "inverseEntityDBName": "note", + "joinColumnName": "note_id", + "joinPropertyName": "note_id", + "relationHash": "bm90ZTpub3RlX2FjY291bnQ6b25lLXRvLW1hbnk=", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 2 + }, + { + "name": "NoteAccount", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_account", + "dbName": "note_account", + "change": "none", + "inverseEntityName": "Account", + "inverseEntityDBName": "account", + "joinColumnName": "account_id", + "joinPropertyName": "account_id", + "relationHash": "YWNjb3VudDpub3RlX2FjY291bnQ6b25lLXRvLW1hbnk=", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 2 + }, + { + "name": "NoteMember", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_member", + "dbName": "note_member", + "change": "none", + "inverseEntityName": "Note", + "inverseEntityDBName": "note", + "joinColumnName": "note_id", + "joinPropertyName": "note_id", + "relationHash": "bm90ZTpub3RlX21lbWJlcjpvbmUtdG8tbWFueQ==", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 2 + }, + { + "name": "NoteMember", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "$kind": "relation", + "entity": "note_member", + "dbName": "note_member", + "change": "none", + "inverseEntityName": "User", + "inverseEntityDBName": "user", + "joinColumnName": "user_id", + "joinPropertyName": "user_id", + "relationHash": "bm90ZV9tZW1iZXI6dXNlcjpvbmUtdG8tbWFueQ==", + "joinColumnOne": false, + "joinColumnNullable": true, + "inverseJoinColumnNullable": false, + "inverseJoinColumnOne": true, + "relationType": "many-to-one", + "isDuplicate": false, + "order": 1 + }, + { + "$kind": "index", + "name": "IDX_9dc72e6309c51e638b7918451c", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "note", + "dbName": "IDX_9dc72e6309c51e638b7918451c", + "tableName": "Note", + "tableDBName": "note", + "isUnique": false, + "isFulltext": false, + "isSpatial": false, + "columnNames": [ + "name" + ] + }, { "$kind": "index", "name": "IDX_e12875dfb3b1d92d7d7c5377e2", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "IDX_e12875dfb3b1d92d7d7c5377e2", @@ -858,9 +1677,9 @@ { "$kind": "index", "name": "IDX_78a916df40e02a9deb1c4b75ed", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "IDX_78a916df40e02a9deb1c4b75ed", @@ -876,9 +1695,9 @@ { "$kind": "index", "name": "UQ_e12875dfb3b1d92d7d7c5377e22", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "UQ_e12875dfb3b1d92d7d7c5377e22", @@ -894,9 +1713,9 @@ { "$kind": "index", "name": "UQ_78a916df40e02a9deb1c4b75edb", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user", "dbName": "UQ_78a916df40e02a9deb1c4b75edb", @@ -912,9 +1731,9 @@ { "$kind": "index", "name": "IDX_414d4052f22837655ff312168c", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "account", "dbName": "IDX_414d4052f22837655ff312168c", @@ -927,30 +1746,12 @@ "name" ] }, - { - "$kind": "index", - "name": "IDX_c2f121740ab4e268b11c677bd1", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", - "change": "none", - "entity": "account_history", - "dbName": "IDX_c2f121740ab4e268b11c677bd1", - "tableName": "AccountHistory", - "tableDBName": "account_history", - "isUnique": false, - "isFulltext": false, - "isSpatial": false, - "columnNames": [ - "action" - ] - }, { "$kind": "index", "name": "IDX_0ac42018737161d3f60307170e", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "IDX_0ac42018737161d3f60307170e", @@ -966,9 +1767,9 @@ { "$kind": "index", "name": "IDX_2eb74e2fc4d76516761bf63b83", - "version": "1728826328125", - "createdAt": "2024-10-13T13:32:08+00:00", - "updatedAt": "2024-10-13T13:32:08+00:00", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", "change": "none", "entity": "user_session", "dbName": "IDX_2eb74e2fc4d76516761bf63b83", @@ -980,5 +1781,23 @@ "columnNames": [ "access_token" ] + }, + { + "$kind": "index", + "name": "IDX_c2f121740ab4e268b11c677bd1", + "version": "1730203163665", + "createdAt": "2024-10-29T11:59:23+00:00", + "updatedAt": "2024-10-29T11:59:23+00:00", + "change": "none", + "entity": "account_history", + "dbName": "IDX_c2f121740ab4e268b11c677bd1", + "tableName": "AccountHistory", + "tableDBName": "account_history", + "isUnique": false, + "isFulltext": false, + "isSpatial": false, + "columnNames": [ + "action" + ] } ] \ No newline at end of file diff --git a/server/.erd/index.html b/server/.erd/index.html index b76483c..ea242ed 100644 --- a/server/.erd/index.html +++ b/server/.erd/index.html @@ -201,15 +201,33 @@ class="bd-aside sticky-xl-top text-body-secondary align-self-start mb-3 mb-xl-5 px-2" >
-

1728826328125

-
@@ -254,24 +299,24 @@

1728826328125

class="form-select form-select-lg mb-3" aria-label="Large select example" > -
-

finote-server 1728826328125

+

finote-server 1730203163665

-

- user (User) +

+ note (Note) #

@@ -280,7 +325,7 @@

@@ -300,21 +345,21 @@

- - - - - - - - @@ -458,33 +503,35 @@

- - - + + +
- user(User) + note(Note) columns
+ # id + # id @@ -341,21 +386,21 @@

+ # created_at + # created_at @@ -380,21 +425,21 @@

+ # updated_at + # updated_at @@ -419,24 +464,24 @@

+ # - email + name + # - email + name
+ # - username + description + # - username + description - *varchar(16) + varchar(100) + NULLABLE + @@ -494,78 +541,142 @@

+

+ +
+ +
+ + + + + + + + + + + + + + - - - - - - + + +
+ + note(Note) + indices +
 Database NameProperty NameUniqueColumns
+ # - password + IDX_9dc72e6309c51e638b7918451c + # - password - - *varchar + IDX_9dc72e6309c51e638b7918451c - +
    +
  • name
  • +
+
+
+
+
+

+ note_transaction + (NoteTransaction) + # +

- - - +
+ + + + + + + + + + + + + + + - - - - + + @@ -577,35 +688,37 @@

- - - + - - - + - -
+ + note_transaction(NoteTransaction) + columns +
 Database NameProperty NameAttributeTypeNullableCharsetComment
+ # - otp_type + id + # - otp_type + id - varchar + PK - NULLABLE + *uuid
+ # - otp + created_at + # - otp + created_at - varchar(6) + *timestamp - NULLABLE - @@ -618,35 +731,37 @@

+ # - otp_expires_at + updated_at + # - otp_expires_at + updated_at - timestamp + *timestamp - NULLABLE - @@ -656,187 +771,239 @@

-
- -
- -
- - - - - - - - - - - - - - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - user(User) - indices -
 Database NameProperty NameUniqueColumns
# - IDX_e12875dfb3b1d92d7d7c5377e2 + note_id # - IDX_e12875dfb3b1d92d7d7c5377e2 + note_id + + FK + + *uuid -
    -
  • email
  • -
+ +
+
# - IDX_78a916df40e02a9deb1c4b75ed + description # - IDX_78a916df40e02a9deb1c4b75ed + description -
    -
  • username
  • -
+ *varchar(100) +
+ + +
# - UQ_e12875dfb3b1d92d7d7c5377e22 + total # - UQ_e12875dfb3b1d92d7d7c5377e22 + total - Unique + + *numeric -
    -
  • email
  • -
+ +
+
# - UQ_78a916df40e02a9deb1c4b75edb + pre_balance # - UQ_78a916df40e02a9deb1c4b75edb + pre_balance - Unique + *numeric -
    -
  • username
  • -
+ +
+ +
+ # + post_balance + + # + post_balance + + *numeric + + + +
+ +
+ +
-

- account (Account) +

+ user (User) #

@@ -845,7 +1012,7 @@

@@ -865,21 +1032,21 @@

- - - - - - - - - - - - - - - - - - - - - - - - - @@ -1064,30 +1190,30 @@

- - @@ -1103,30 +1229,30 @@

- - @@ -1142,30 +1268,30 @@

- - - - - - - - - - - - - - - - - - - - - @@ -1261,33 +1350,35 @@

- - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- account(Account) + user(User) columns
+ # id + # id @@ -906,21 +1073,21 @@

+ # created_at + # created_at @@ -945,21 +1112,21 @@

+ # updated_at + # updated_at @@ -984,65 +1151,24 @@

- # - user_id - - # - user_id - - FK - - *uuid - - - - -
+ # - type + email + # - type + email
+ # - currency + username + # - currency + username - *varchar + *varchar(16)
+ # - name + password + # - name + password - *varchar(100) + *varchar
+ # - reference + otp_type + # - reference + otp_type - varchar(50) + varchar @@ -1183,73 +1309,36 @@

+ # - balance + otp + # - balance - - *numeric + otp - - - -
- # - minimum_balance - - # - minimum_balance + varchar(6) - *numeric + NULLABLE
+ # - version + otp_expires_at + # - version + otp_expires_at - *int4 + timestamp + NULLABLE + @@ -1307,7 +1398,7 @@

@@ -1326,56 +1417,1810 @@

- -
- account(Account) + user(User) indices
# - IDX_414d4052f22837655ff312168c + IDX_e12875dfb3b1d92d7d7c5377e2 # - IDX_414d4052f22837655ff312168c + IDX_e12875dfb3b1d92d7d7c5377e2
    -
  • name
  • +
  • email
- -
- -
-

- account_history - (AccountHistory) - # -

+

+ # + IDX_78a916df40e02a9deb1c4b75ed + + # + IDX_78a916df40e02a9deb1c4b75ed + +
    +
  • username
  • +
+
+ # + UQ_e12875dfb3b1d92d7d7c5377e22 + + # + UQ_e12875dfb3b1d92d7d7c5377e22 + + Unique + +
    +
  • email
  • +
+
+ # + UQ_78a916df40e02a9deb1c4b75edb + + # + UQ_78a916df40e02a9deb1c4b75edb + + Unique + +
    +
  • username
  • +
+
+

+
+ +
+

+ account (Account) + # +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + account(Account) + columns +
 Database NameProperty NameAttributeTypeNullableCharsetComment
+ # + id + + # + id + + PK + + *uuid + + + + +
+ # + created_at + + # + created_at + + *timestamp + + + + +
+ # + updated_at + + # + updated_at + + *timestamp + + + + +
+ # + user_id + + # + user_id + + FK + + *uuid + + + + +
+ # + type + + # + type + + *varchar + + + + +
+ # + currency + + # + currency + + *varchar + + + + +
+ # + name + + # + name + + *varchar(100) + + + + +
+ # + reference + + # + reference + + varchar(50) + + NULLABLE + + + + +
+ # + balance + + # + balance + + *numeric + + + + +
+ # + minimum_balance + + # + minimum_balance + + *numeric + + + + +
+ # + version + + # + version + + *int4 + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + account(Account) + indices +
 Database NameProperty NameUniqueColumns
+ # + IDX_414d4052f22837655ff312168c + + # + IDX_414d4052f22837655ff312168c + +
    +
  • name
  • +
+
+
+
+
+
+

+ note_item (NoteItem) + # +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + note_item(NoteItem) + columns +
 Database NameProperty NameAttributeTypeNullableCharsetComment
+ # + id + + # + id + + PK + + *uuid + + + + +
+ # + created_at + + # + created_at + + *timestamp + + + + +
+ # + updated_at + + # + updated_at + + *timestamp + + + + +
+ # + transaction_id + + # + transaction_id + + FK + + *uuid + + + + +
+ # + account_id + + # + account_id + + FK + + *uuid + + + + +
+ # + user_id + + # + user_id + + FK + + *uuid + + + + +
+ # + name + + # + name + + *varchar(100) + + + + +
+ # + amount + + # + amount + + *numeric + + + + +
+ # + is_over_budget + + # + is_over_budget + + *smallint + + + + +
+
+ +
+ +
+
+
+
+

+ user_session + (UserSession) + # +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + user_session(UserSession) + columns +
 Database NameProperty NameAttributeTypeNullableCharsetComment
+ # + id + + # + id + + PK + + *uuid + + + + +
+ # + created_at + + # + created_at + + *timestamp + + + + +
+ # + updated_at + + # + updated_at + + *timestamp + + + + +
+ # + user_id + + # + user_id + + FK + + *uuid + + + + +
+ # + refresh_token + + # + refresh_token + + varchar + + NULLABLE + + + + +
+ # + refresh_token_expires_at + + # + refresh_token_expires_at + + timestamp + + NULLABLE + + + + +
+ # + user_agent + + # + user_agent + + *varchar + + + + +
+ # + ip_address + + # + ip_address + + *varchar + + + + +
+ # + is_blocked + + # + is_blocked + + *smallint + + + + +
+ # + attempt + + # + attempt + + *int + + + + +
+ # + access_token + + # + access_token + + varchar + + NULLABLE + + + + +
+ # + access_token_expires_at + + # + access_token_expires_at + + timestamp + + NULLABLE + + + + +
+ # + is_verified + + # + is_verified + + *smallint + + + + +
+ # + last_login + + # + last_login + + timestamp + + NULLABLE + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + user_session(UserSession) + indices +
 Database NameProperty NameUniqueColumns
+ # + IDX_0ac42018737161d3f60307170e + + # + IDX_0ac42018737161d3f60307170e + +
    +
  • refresh_token
  • +
+
+ # + IDX_2eb74e2fc4d76516761bf63b83 + + # + IDX_2eb74e2fc4d76516761bf63b83 + +
    +
  • access_token
  • +
+
+
+
+
+
+

+ account_history + (AccountHistory) + # +

@@ -1403,20 +3248,20 @@

- -
+ # id + # @@ -1445,11 +3290,11 @@

# @@ -1457,11 +3302,11 @@

# @@ -1488,11 +3333,11 @@

# @@ -1500,11 +3345,11 @@

# @@ -1531,11 +3376,11 @@

# @@ -1543,11 +3388,11 @@

# @@ -1576,11 +3421,11 @@

# @@ -1588,11 +3433,11 @@

# @@ -1619,11 +3464,11 @@

# @@ -1631,11 +3476,11 @@

# @@ -1662,11 +3507,11 @@

# @@ -1674,11 +3519,11 @@

# @@ -1705,11 +3550,11 @@

# @@ -1717,11 +3562,11 @@

# @@ -1775,11 +3620,11 @@

# @@ -1787,11 +3632,11 @@

# @@ -1812,13 +3657,13 @@

-

- user_session - (UserSession) +

+ note_account + (NoteAccount) #

@@ -1827,8 +3672,8 @@

@@ -1844,205 +3689,41 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + @@ -2054,39 +3735,33 @@

- - - + - - @@ -2138,30 +3813,32 @@

- - - + @@ -2177,30 +3854,32 @@

- - - + @@ -2213,33 +3892,79 @@

+ +
- user_session(UserSession)(NoteAccount) columns
Charset Comment
- # - id - - # - id - - PK - - *uuid - - - - -
- # - created_at - - # - created_at - - *timestamp - - - - -
- # - updated_at - - # - updated_at - - *timestamp - - - - -
- # - user_id - - # - user_id - - FK - - *uuid - - - - -
+ # - refresh_token + id + # - refresh_token + id - varchar + PK - NULLABLE + *uuid
+ # - refresh_token_expires_at + created_at + # - refresh_token_expires_at + created_at - timestamp + *timestamp - NULLABLE - @@ -2099,30 +3774,30 @@

+ # - user_agent + updated_at + # - user_agent + updated_at - *varchar + *timestamp
+ # - ip_address + note_id + # - ip_address + note_id + FK + - *varchar + *uuid
+ # - is_blocked + account_id + # - is_blocked + account_id + FK + - *smallint + *uuid
+

+ +
+ +
+
+ +
+

+ note_member + (NoteMember) + # +

+ +
+ + + + + + + + + + + + + + + + - - - + @@ -2255,39 +3980,33 @@

- - - + - - - + - - - + @@ -2384,36 +4099,36 @@

- - - - + + @@ -2428,100 +4143,7 @@

-
-

+ + note_member(NoteMember) + columns +
 Database NameProperty NameAttributeTypeNullableCharsetComment
+ # - attempt + id + # - attempt + id + PK + - *int + *uuid
+ # - access_token + created_at + # - access_token + created_at - varchar + *timestamp - NULLABLE - @@ -2300,39 +4019,33 @@

+ # - access_token_expires_at + updated_at + # - access_token_expires_at + updated_at - timestamp + *timestamp - NULLABLE - @@ -2345,30 +4058,32 @@

+ # - is_verified + note_id + # - is_verified + note_id + FK + - *smallint + *uuid
+ # - last_login + user_id + # - last_login + user_id - timestamp + FK - NULLABLE + *uuid
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - user_session(UserSession) - indices -
 Database NameProperty NameUniqueColumns
- # - IDX_0ac42018737161d3f60307170e - - # - IDX_0ac42018737161d3f60307170e - -
    -
  • refresh_token
  • -
-
- # - IDX_2eb74e2fc4d76516761bf63b83 - - # - IDX_2eb74e2fc4d76516761bf63b83 - -
    -
  • access_token
  • -
-
-
+
diff --git a/server/.erd/mermaid.html b/server/.erd/mermaid.html index 8119ea9..a8ab440 100644 --- a/server/.erd/mermaid.html +++ b/server/.erd/mermaid.html @@ -242,6 +242,30 @@

Diagram

erDiagram +"note(Note)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *varchar name + varchar(100) description +} + + + +"note_transaction(NoteTransaction)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *varchar(100) description + *numeric total + *numeric pre_balance + *numeric post_balance +} + + +"note_transaction(NoteTransaction)" }o -- || "note(Note)": "note_id" + "user(User)" { *uuid id PK *timestamp created_at @@ -273,19 +297,22 @@

Diagram

"account(Account)" }o -- || "user(User)": "user_id" -"account_history(AccountHistory)" { +"note_item(NoteItem)" { *uuid id PK *timestamp created_at *timestamp updated_at + *uuid transaction_id FK *uuid account_id FK - *varchar action - *varchar description - *numeric pre_balance - *numeric post_balance + *uuid user_id FK + *varchar(100) name + *numeric amount + *smallint is_over_budget } -"account_history(AccountHistory)" }o -- || "account(Account)": "account_id" +"note_item(NoteItem)" }o -- || "note_transaction(NoteTransaction)": "transaction_id" +"note_item(NoteItem)" }o -- || "account(Account)": "account_id" +"note_item(NoteItem)" }o -- || "user(User)": "user_id" "user_session(UserSession)" { *uuid id PK @@ -307,6 +334,44 @@

Diagram

"user_session(UserSession)" }o -- || "user(User)": "user_id" +"account_history(AccountHistory)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid account_id FK + *varchar action + *varchar description + *numeric pre_balance + *numeric post_balance +} + + +"account_history(AccountHistory)" }o -- || "account(Account)": "account_id" + +"note_account(NoteAccount)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *uuid account_id FK +} + + +"note_account(NoteAccount)" }o -- || "note(Note)": "note_id" +"note_account(NoteAccount)" }o -- || "account(Account)": "account_id" + +"note_member(NoteMember)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *uuid user_id FK +} + + +"note_member(NoteMember)" }o -- || "note(Note)": "note_id" +"note_member(NoteMember)" }o -- || "user(User)": "user_id" + @@ -330,6 +395,30 @@

erDiagram +"note(Note)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *varchar name + varchar(100) description +} + + + +"note_transaction(NoteTransaction)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *varchar(100) description + *numeric total + *numeric pre_balance + *numeric post_balance +} + + +"note_transaction(NoteTransaction)" }o -- || "note(Note)": "note_id" + "user(User)" { *uuid id PK *timestamp created_at @@ -361,19 +450,22 @@

"account(Account)" }o -- || "user(User)": "user_id" -"account_history(AccountHistory)" { +"note_item(NoteItem)" { *uuid id PK *timestamp created_at *timestamp updated_at + *uuid transaction_id FK *uuid account_id FK - *varchar action - *varchar description - *numeric pre_balance - *numeric post_balance + *uuid user_id FK + *varchar(100) name + *numeric amount + *smallint is_over_budget } -"account_history(AccountHistory)" }o -- || "account(Account)": "account_id" +"note_item(NoteItem)" }o -- || "note_transaction(NoteTransaction)": "transaction_id" +"note_item(NoteItem)" }o -- || "account(Account)": "account_id" +"note_item(NoteItem)" }o -- || "user(User)": "user_id" "user_session(UserSession)" { *uuid id PK @@ -395,6 +487,44 @@

"user_session(UserSession)" }o -- || "user(User)": "user_id" +"account_history(AccountHistory)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid account_id FK + *varchar action + *varchar description + *numeric pre_balance + *numeric post_balance +} + + +"account_history(AccountHistory)" }o -- || "account(Account)": "account_id" + +"note_account(NoteAccount)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *uuid account_id FK +} + + +"note_account(NoteAccount)" }o -- || "note(Note)": "note_id" +"note_account(NoteAccount)" }o -- || "account(Account)": "account_id" + +"note_member(NoteMember)" { + *uuid id PK + *timestamp created_at + *timestamp updated_at + *uuid note_id FK + *uuid user_id FK +} + + +"note_member(NoteMember)" }o -- || "note(Note)": "note_id" +"note_member(NoteMember)" }o -- || "user(User)": "user_id" + diff --git a/server/src/databases/entities/core/note-account.entity.ts b/server/src/databases/entities/core/note-account.entity.ts new file mode 100644 index 0000000..73edc54 --- /dev/null +++ b/server/src/databases/entities/core/note-account.entity.ts @@ -0,0 +1,21 @@ +import BaseEntity from '@db/entities/base/base'; +import { CoreEntity } from '@db/entities/base/core'; +import { ForeignColumn } from '@libs/typeorm/column-decorator.typeorm'; +import { ManyToOne } from 'typeorm'; +import { Note } from '@db/entities/core/note.entity'; +import { Account } from '@db/entities/core/account.entity'; + +@CoreEntity() +export class NoteAccount extends BaseEntity { + @ForeignColumn() + note_id: string; + + @ManyToOne(() => Note, { onDelete: 'CASCADE' }) + note: Note; + + @ForeignColumn() + account_id: string; + + @ManyToOne(() => Account, { onDelete: 'SET NULL' }) + account: Note; +} diff --git a/server/src/databases/entities/core/note-item.entity.ts b/server/src/databases/entities/core/note-item.entity.ts new file mode 100644 index 0000000..2af9cc3 --- /dev/null +++ b/server/src/databases/entities/core/note-item.entity.ts @@ -0,0 +1,38 @@ +import BaseEntity from '@db/entities/base/base'; +import { CoreEntity } from '@db/entities/base/core'; +import { AmountColumn, BooleanColumn, ForeignColumn, StringColumn } from '@libs/typeorm/column-decorator.typeorm'; +import { ManyToOne } from 'typeorm'; +import { NoteTransaction } from '@db/entities/core/note-transaction.entity'; +import { Account } from '@db/entities/core/account.entity'; +import { DecimalNumber } from '@libs/helpers/decimal.helper'; +import { User } from '@db/entities/core/user.entity'; + +@CoreEntity() +export class NoteItem extends BaseEntity { + @ForeignColumn() + transaction_id: string; + + @ManyToOne(() => NoteTransaction, { onDelete: 'CASCADE' }) + transaction: NoteTransaction; + + @ForeignColumn() + account_id: string; + + @ManyToOne(() => Account, { onDelete: 'SET NULL' }) + account: Account; + + @ForeignColumn() + user_id: string; + + @ManyToOne(() => User, { onDelete: 'SET NULL' }) + user: User; + + @StringColumn({ nullable: false, length: 100 }) + name: string; + + @AmountColumn({ nullable: false }) + amount: DecimalNumber; + + @BooleanColumn({ nullable: false, default: false }) + is_over_budget: boolean; +} diff --git a/server/src/databases/entities/core/note-member.entity.ts b/server/src/databases/entities/core/note-member.entity.ts new file mode 100644 index 0000000..9026d28 --- /dev/null +++ b/server/src/databases/entities/core/note-member.entity.ts @@ -0,0 +1,21 @@ +import BaseEntity from '@db/entities/base/base'; +import { CoreEntity } from '@db/entities/base/core'; +import { ForeignColumn } from '@libs/typeorm/column-decorator.typeorm'; +import { ManyToOne } from 'typeorm'; +import { Note } from '@db/entities/core/note.entity'; +import { User } from '@db/entities/core/user.entity'; + +@CoreEntity() +export class NoteMember extends BaseEntity { + @ForeignColumn() + note_id: string; + + @ManyToOne(() => Note, { onDelete: 'CASCADE' }) + note: Note; + + @ForeignColumn() + user_id: string; + + @ManyToOne(() => User, { onDelete: 'SET NULL' }) + user: User; +} diff --git a/server/src/databases/entities/core/note-transaction.entity.ts b/server/src/databases/entities/core/note-transaction.entity.ts new file mode 100644 index 0000000..029e834 --- /dev/null +++ b/server/src/databases/entities/core/note-transaction.entity.ts @@ -0,0 +1,27 @@ +import BaseEntity from '@db/entities/base/base'; +import { CoreEntity } from '@db/entities/base/core'; +import { AmountColumn, ForeignColumn, StringColumn } from '@libs/typeorm/column-decorator.typeorm'; +import { ManyToOne } from 'typeorm'; +import { Note } from '@db/entities/core/note.entity'; +import { DecimalNumber } from '@libs/helpers/decimal.helper'; + +@CoreEntity() +export class NoteTransaction extends BaseEntity { + @ForeignColumn() + note_id: string; + + @ManyToOne(() => Note, { onDelete: 'CASCADE' }) + note: Note; + + @StringColumn({ nullable: false, length: 100 }) + description: string; + + @AmountColumn({ nullable: false }) + total: DecimalNumber; + + @AmountColumn({ nullable: false }) + pre_balance: DecimalNumber; + + @AmountColumn({ nullable: false }) + post_balance: DecimalNumber; +} diff --git a/server/src/databases/entities/core/note.entity.ts b/server/src/databases/entities/core/note.entity.ts new file mode 100644 index 0000000..d8929dd --- /dev/null +++ b/server/src/databases/entities/core/note.entity.ts @@ -0,0 +1,14 @@ +import { CoreEntity } from '@db/entities/base/core'; +import BaseEntity from '@db/entities/base/base'; +import { StringColumn } from '@libs/typeorm/column-decorator.typeorm'; +import { Index } from 'typeorm'; + +@CoreEntity() +export class Note extends BaseEntity { + @Index() + @StringColumn({ nullable: false }) + name: string; + + @StringColumn({ nullable: true, length: 100 }) + description: string | null; +} diff --git a/server/src/databases/migrations/1730203011356-note.ts b/server/src/databases/migrations/1730203011356-note.ts new file mode 100644 index 0000000..79a035b --- /dev/null +++ b/server/src/databases/migrations/1730203011356-note.ts @@ -0,0 +1,69 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class Note1730203011356 implements MigrationInterface { + name = 'Note1730203011356'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "note" ("id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying NOT NULL, "description" character varying(100), CONSTRAINT "PK_96d0c172a4fba276b1bbed43058" PRIMARY KEY ("id"))`, + ); + await queryRunner.query(`CREATE INDEX "IDX_9dc72e6309c51e638b7918451c" ON "note" ("name") `); + await queryRunner.query( + `CREATE TABLE "note_member" ("id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "note_id" uuid NOT NULL, "user_id" uuid NOT NULL, CONSTRAINT "PK_ca3bbea040cc161ad5cdc068c00" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "note_transaction" ("id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "note_id" uuid NOT NULL, "description" character varying(100) NOT NULL, "total" numeric(10,2) NOT NULL, "pre_balance" numeric(10,2) NOT NULL, "post_balance" numeric(10,2) NOT NULL, CONSTRAINT "PK_eec4c67afbeb13bf936255fb3da" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "note_item" ("id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "transaction_id" uuid NOT NULL, "account_id" uuid NOT NULL, "user_id" uuid NOT NULL, "name" character varying(100) NOT NULL, "amount" numeric(10,2) NOT NULL, "is_over_budget" smallint NOT NULL DEFAULT '0', CONSTRAINT "PK_eeb5901759f08fdf8e4447fa86c" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "note_account" ("id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "note_id" uuid NOT NULL, "account_id" uuid NOT NULL, CONSTRAINT "PK_947f7c631ddce8eb49cd69787b8" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "account" ADD CONSTRAINT "CHK_812bd5b0ac292270acdabc5bfc" CHECK ("balance" >= "minimum_balance")`, + ); + await queryRunner.query( + `ALTER TABLE "note_member" ADD CONSTRAINT "FK_1aac3cf8cfa6bee1c59d8a77747" FOREIGN KEY ("note_id") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_member" ADD CONSTRAINT "FK_56f02fe522d7bf8ca006d56706c" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_transaction" ADD CONSTRAINT "FK_5e86c9a26f005338dc82a7a0148" FOREIGN KEY ("note_id") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_item" ADD CONSTRAINT "FK_b3dc75b2d17464cfd63636d3082" FOREIGN KEY ("transaction_id") REFERENCES "note_transaction"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_item" ADD CONSTRAINT "FK_702f5c5af1dc2319762b0383496" FOREIGN KEY ("account_id") REFERENCES "account"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_item" ADD CONSTRAINT "FK_b51d4db743106ac7e974b4043c3" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_account" ADD CONSTRAINT "FK_0ac5b0e3c4e19b2049fb6009096" FOREIGN KEY ("note_id") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "note_account" ADD CONSTRAINT "FK_af7cccffed37d76fd799ccfbcc9" FOREIGN KEY ("account_id") REFERENCES "account"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "note_account" DROP CONSTRAINT "FK_af7cccffed37d76fd799ccfbcc9"`); + await queryRunner.query(`ALTER TABLE "note_account" DROP CONSTRAINT "FK_0ac5b0e3c4e19b2049fb6009096"`); + await queryRunner.query(`ALTER TABLE "note_item" DROP CONSTRAINT "FK_b51d4db743106ac7e974b4043c3"`); + await queryRunner.query(`ALTER TABLE "note_item" DROP CONSTRAINT "FK_702f5c5af1dc2319762b0383496"`); + await queryRunner.query(`ALTER TABLE "note_item" DROP CONSTRAINT "FK_b3dc75b2d17464cfd63636d3082"`); + await queryRunner.query(`ALTER TABLE "note_transaction" DROP CONSTRAINT "FK_5e86c9a26f005338dc82a7a0148"`); + await queryRunner.query(`ALTER TABLE "note_member" DROP CONSTRAINT "FK_56f02fe522d7bf8ca006d56706c"`); + await queryRunner.query(`ALTER TABLE "note_member" DROP CONSTRAINT "FK_1aac3cf8cfa6bee1c59d8a77747"`); + await queryRunner.query(`ALTER TABLE "account" DROP CONSTRAINT "CHK_812bd5b0ac292270acdabc5bfc"`); + await queryRunner.query(`DROP TABLE "note_account"`); + await queryRunner.query(`DROP TABLE "note_item"`); + await queryRunner.query(`DROP TABLE "note_transaction"`); + await queryRunner.query(`DROP TABLE "note_member"`); + await queryRunner.query(`DROP INDEX "public"."IDX_9dc72e6309c51e638b7918451c"`); + await queryRunner.query(`DROP TABLE "note"`); + } +}