Files
threshold/internal/db/sqltest/tests/wh/upsert_user/insert.sql
T
Timothy Messier 026f09a9a8 refactor(wh): Rename primary and foreign key columns
The tables in the operational part of the Boundary database (meaning
non-warehouse tables) suffix primary key columns and foreign key columns
with `_id`. Many of these columns appear in the warehouse dimension and
fact tables as normal attributes, not primary keys or foreign keys. To
disambiguate ID columns from operational tables, the primary key column
for dimension tables will be renamed from `id` to `key` and the foreign
key columns in the fact tables will be renamed to change the suffix from
`_id` to `_key`.
2021-08-30 14:25:30 -04:00

18 lines
590 B
PL/PgSQL

-- insert tests that the wh_upsert_user function will do an insert when
-- no existing source wh_user_dimension exists.
begin;
select plan(3);
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets');
-- ensure no existing dimensions
select is(count(*), 0::bigint) from wh_user_dimension where user_id = 'u_____walter';
select lives_ok($$select wh_upsert_user('u_____walter', 'tok___walter')$$);
-- upsert should insert a user_dimension
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____walter';
select * from finish();
rollback;