Add not null checks to wt_private_id, wt_scope_id, and wt_user_id (#284)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-19 21:45:46 -04:00
1 parent 9570897032
commit 6bf4a5ce38
8 files changed
+162 -64

No files matched your search

@@ -57,15 +57,21 @@ begin;
*/
create table auth_password_method (
public_id wt_public_id primary key,
scope_id wt_scope_id not null,
password_conf_id wt_private_id not null, -- FK to auth_password_conf added below
public_id wt_public_id
primary key,
scope_id wt_scope_id
not null,
password_conf_id wt_private_id, -- FK to auth_password_conf added below
name text,
description text,
create_time wt_timestamp,
update_time wt_timestamp,
min_login_name_length int not null default 3,
min_password_length int not null default 8,
min_login_name_length int
not null
default 3,
min_password_length int
not null
default 8,
version wt_version,
foreign key (scope_id, public_id)
references auth_method (scope_id, public_id)
@@ -86,8 +92,10 @@ begin;
for each row execute procedure insert_auth_method_subtype();
create table auth_password_account (
public_id wt_public_id primary key,
auth_method_id wt_public_id not null,
public_id wt_public_id
primary key,
auth_method_id wt_public_id
not null,
-- NOTE(mgaffney): The scope_id type is not wt_scope_id because the domain
-- check is executed before the insert trigger which retrieves the scope_id
-- causing an insert to fail.
@@ -127,8 +135,10 @@ begin;
for each row execute procedure insert_auth_account_subtype();
create table auth_password_conf (
private_id wt_private_id primary key,
password_method_id wt_public_id not null
private_id wt_private_id
primary key,
password_method_id wt_public_id
not null
references auth_password_method (public_id)
on delete cascade
on update cascade
@@ -160,10 +170,14 @@ begin;
$$ language plpgsql;
create table auth_password_credential (
private_id wt_private_id primary key,
password_account_id wt_public_id not null unique,
password_conf_id wt_private_id not null,
password_method_id wt_public_id not null,
private_id wt_private_id
primary key,
password_account_id wt_public_id
not null
unique,
password_conf_id wt_private_id,
password_method_id wt_public_id
not null,
foreign key (password_method_id, password_conf_id)
references auth_password_conf (password_method_id, private_id)
on delete cascade