-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1144 from dm3-org/develop
Release 1.6
- Loading branch information
Showing
162 changed files
with
5,041 additions
and
3,211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/backend/manual_data_migration/insertWithinDocker.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Input file | ||
input_file="dump.txt" | ||
|
||
DB_NAME="dm3" | ||
DB_USER="prisma" | ||
|
||
|
||
# Read the input file line by line | ||
while IFS= read -r line | ||
do | ||
# Extract the ID (first part of the line) and timestamp (after "createdAt") | ||
id=$(echo "$line" | cut -d ':' -f 2) | ||
timestamp=$(echo "$line" | grep -oP '(?<="createdAt":)[0-9]+') | ||
|
||
# Convert the timestamp from milliseconds to seconds | ||
timestamp_seconds=$(echo $timestamp | sed 's/...$//') | ||
|
||
# Insert the extracted values into the PostgreSQL table | ||
psql -U $DB_USER -d $DB_NAME -c "INSERT INTO \"Account\" (id, \"createdAt\") \ | ||
VALUES ('$id', to_timestamp($timestamp_seconds))\ | ||
ON CONFLICT (id) \ | ||
DO UPDATE SET \"createdAt\" = excluded.\"createdAt\";" | ||
|
||
done < "$input_file" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Process: | ||
|
||
check data | ||
`docker exec -it dm3-db-1 redis-cli --scan --pattern 'session*addr.dm3.eth'` | ||
|
||
`docker exec -it dm3-storage psql -U prisma -d dm3 -c 'SELECT * FROM "Account";'` | ||
|
||
go into the redis container | ||
docker exec -it dm3-db-1 bash | ||
|
||
dump all relevant sessions | ||
for key in `redis-cli --scan --pattern 'session*addr.dm3.eth'`; do echo $key: `redis-cli GET $key` >> dump.txt; echo $key; done | ||
|
||
copy the dump to the host | ||
docker cp dm3-db-1:/data/dump.txt . | ||
|
||
copy the dump to the postgres container | ||
docker cp dump.txt dm3-storage:/ | ||
|
||
paste script onto server | ||
vi insertWithinDocker.sh | ||
-> paste, close | ||
|
||
copy the script to the postgres container | ||
docker cp insertWithinDocker.sh dm3-storage:/ | ||
|
||
go into the postgres container | ||
docker exec -it dm3-storage bash | ||
|
||
make script executable | ||
chmod a+x insertWithinDocker.sh | ||
|
||
run the script | ||
./insertWithinDocker.sh | ||
|
||
check the data from outside the container | ||
docker exec -it dm3-storage psql -U prisma -d dm3 -c 'SELECT \* FROM "Account";' |
2 changes: 2 additions & 0 deletions
2
packages/backend/migrations/20240719092732_add_account_created_at/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Account" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Conversation" ADD COLUMN "encryptedProfileLocation" TEXT NOT NULL DEFAULT ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
packages/backend/src/persistence/account/setAccount.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { UserProfile } from '@dm3-org/dm3-lib-profile'; | ||
import { PrismaClient } from '@prisma/client'; | ||
import { IBackendDatabase, getDatabase, getPrismaClient } from '../getDatabase'; | ||
|
||
const USER_NAME = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292.dm3.eth'; | ||
|
||
describe('Set Account', () => { | ||
let prismaClient: PrismaClient; | ||
let db: IBackendDatabase; | ||
|
||
beforeEach(async () => { | ||
prismaClient = await getPrismaClient(); | ||
db = await getDatabase(prismaClient); | ||
}); | ||
|
||
it('Creates a new Account ', async () => { | ||
const profile: UserProfile = { | ||
publicEncryptionKey: '', | ||
publicSigningKey: '', | ||
deliveryServices: [], | ||
}; | ||
|
||
const priorSetAccount = await db.getAccount(USER_NAME); | ||
|
||
//User has no account yet | ||
expect(priorSetAccount).toBe(null); | ||
await db.setAccount(USER_NAME); | ||
|
||
const afterSetAccount = await db.getAccount(USER_NAME); | ||
//User has no account yet | ||
expect(afterSetAccount?.id).toEqual(USER_NAME); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
packages/backend/src/persistence/session/setAccount.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.