Skip to content

Commit 1eecd0e

Browse files
committed
Create app user, or just update password.
1 parent 67ddf0a commit 1eecd0e

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.github/actions/database-migration-image/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Variation specific to the deploy environment will go here
2-
ARG IMAGE
2+
ARG IMAGE=ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/schema_installer:latest-dev
33
FROM ${IMAGE}
44

55
COPY entry.sh /
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
-- TODO; need to update cdk setup before this is useful
2-
-- File here created as placeholder and reminder.
1+
set define on
2+
@/tmp/cda-user-info
3+
4+
begin
5+
-- create user
6+
cwms_sec.add_cwms_user('&&cda_user', NULL, 'HQ');
7+
-- set permissions for all offices
8+
for ofc in (select office_id from av_office where office_id not in ('CWMS', 'UNK'))
9+
loop
10+
cwms_sec.add_user_to_group('&&cda_user','All Users', ofc.office_id);
11+
cwms_sec.add_user_to_group('&&cda_user','CWMS Users', ofc.office_id);
12+
cwms_sec.add_user_to_group('&&cda_user','CWMS DBA Users', ofc.office_id);
13+
cwms_sec.add_user_to_group('&&cda_user','CWMS User Admins', ofc.office_id);
14+
cwms_sec.add_user_to_group('&&cda_user','CWMS PD Users', ofc.office_id);
15+
end loop;
16+
end;
17+
/
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
#!/bin/bash
22

3-
# STOP GAP, need to reset the migration container mappings
4-
export BUILDUSER_PASSWORD=$SYS_PASSWORD
5-
export TEST_ACCOUNT="-notestaccount"
3+
cat > /tmp/create-app-user.sql <<EOF
4+
declare
5+
user_count integer;
6+
begin
7+
select count(*) into user_count from dba_users where username='&1';
8+
if (user_count = 0) then
9+
execute immediate 'create user &1 identified by "&2"';
10+
else
11+
execute immediate 'alter user &1 identified by "&2"';
12+
end if;
13+
end;
14+
/
15+
EOF
16+
17+
cat > /tmp/cda-user-info.sql <<EOF
18+
define cda_user='$CDA_USERNAME';
19+
EOF
20+
21+
# Create app user first, one of the migration steps is to update the "cwms user" information for that user
22+
23+
sqlplus $BUILDUSER/$BUILDUSER_PASSWORD@$DB_HOST_PORT$DB_NAME @/tmp/create-app-user "$CDA_USERNAME" "$CDA_PASSWORD"
624

725
exec $*

0 commit comments

Comments
 (0)