Skip to content

Commit

Permalink
SKFP-354 Migration from persona to users-api (for Kidsfirst, will be …
Browse files Browse the repository at this point in the history
…removed after persona cut) (#74)
  • Loading branch information
celinepelletier authored Jul 8, 2024
1 parent dc690e2 commit 49eec8f
Show file tree
Hide file tree
Showing 15 changed files with 678 additions and 38 deletions.
28 changes: 28 additions & 0 deletions migrations/1719943513629_add-kf-columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Up Migration
ALTER TABLE users
ADD COLUMN newsletter_dataset_subscription_status TEXT;
ALTER TABLE users
ADD COLUMN location_country CITEXT;
ALTER TABLE users
ADD COLUMN location_state CITEXT;
ALTER TABLE users
ADD COLUMN website TEXT;
ALTER TABLE users
ADD COLUMN areas_of_interest CITEXT[];
ALTER TABLE users
ADD COLUMN is_public BOOLEAN NOT NULL DEFAULT false;
UPDATE users SET is_public = true;

-- Down Migration
ALTER TABLE users
DROP COLUMN newsletter_dataset_subscription_status;
ALTER TABLE users
DROP COLUMN location_country;
ALTER TABLE users
DROP COLUMN location_state;
ALTER TABLE users
DROP COLUMN website;
ALTER TABLE users
DROP COLUMN areas_of_interest;
ALTER TABLE users
DROP COLUMN is_public;
5 changes: 5 additions & 0 deletions migrations/1719944573861_remove-unused-nih-ned-id.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Up Migration
ALTER TABLE users DROP COLUMN nih_ned_id;

-- Down Migration
ALTER TABLE users ADD COLUMN nih_ned_id VARCHAR(255);
111 changes: 101 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.312.0",
"@fast-csv/parse": "^5.0.0",
"@types/pg-format": "^1.0.2",
"@types/validator": "^13.7.1",
"cors": "^2.8.5",
Expand All @@ -36,7 +37,8 @@
"node-pg-migrate": "^6.0.0",
"pg": "^8.7.1",
"sequelize": "^6.28.2",
"uuidv4": "^6.2.13"
"uuidv4": "^6.2.13",
"validator": "^13.12.0"
},
"devDependencies": {
"@types/cors": "^2.8.12",
Expand Down
2 changes: 2 additions & 0 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export const adminRoleName = process.env.ADMIN_ROLE_NAME || 'admin';

export const smartsheetId = process.env.SMARTSHEET_ID;
export const smartsheetToken = process.env.SMARTSHEET_TOKEN;

export const personaURL = process.env.PERSONA_URL || 'not supported';
4 changes: 2 additions & 2 deletions src/db/dal/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const sanitizeInputPayload = (payload: IUserInput) => {
creation_date,
email,
era_commons_id,
nih_ned_id,
newsletter_email,
newsletter_subscription_status,
newsletter_dataset_subscription_status,
...rest
} = payload;

Expand Down Expand Up @@ -112,6 +112,7 @@ export const searchUsers = async ({
where: {
[Op.and]: {
completed_registration: true,
is_public: true,
deleted: false,
...matchClauses,
[Op.and]: andClauses,
Expand Down Expand Up @@ -225,7 +226,6 @@ export const deleteUser = async (keycloak_id: string): Promise<void> => {
email: null,
affiliation: null,
public_email: null,
nih_ned_id: null,
era_commons_id: null,
first_name: null,
last_name: null,
Expand Down
Loading

0 comments on commit 49eec8f

Please sign in to comment.