fix not null constraint

The default not null constraint only checks for the SQL null, not a json
null.
Therefore add an extended not null constraint by checking both possible
null values.
This commit is contained in:
Gibheer 2021-05-21 20:53:50 +02:00
parent c5f0a86886
commit f28b0d0ae3
1 changed files with 9 additions and 9 deletions

View File

@ -1,7 +1,7 @@
create table if not exists layer3domains( create table if not exists layer3domains(
id serial not null primary key, id serial not null primary key,
name varchar(128) not null unique, name varchar(128) not null unique,
attributes jsonb not null default '{}', attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -12,7 +12,7 @@ create table if not exists pools(
id serial not null, id serial not null,
layer3domain_id integer not null references layer3domains(id), layer3domain_id integer not null references layer3domains(id),
name varchar(128) unique, name varchar(128) unique,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -24,7 +24,7 @@ create table containers(
layer3domain_id integer not null references layer3domains(id), layer3domain_id integer not null references layer3domains(id),
subnet cidr not null, subnet cidr not null,
pool_id integer, pool_id integer,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -50,7 +50,7 @@ create table if not exists ips(
layer3domain_id integer not null, layer3domain_id integer not null,
version smallint not null, version smallint not null,
address inet not null, address inet not null,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -61,7 +61,7 @@ create table if not exists ips(
create table if not exists zones( create table if not exists zones(
id serial not null primary key, id serial not null primary key,
name varchar not null unique, name varchar not null unique,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -80,7 +80,7 @@ create table if not exists zoneviews(
retry integer not null default 900, retry integer not null default 900,
expire integer not null default 604800, expire integer not null default 604800,
minimum bigint not null default 86400, minimum bigint not null default 86400,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -94,7 +94,7 @@ create table if not exists records(
type varchar(11) not null, type varchar(11) not null,
ttl integer, ttl integer,
value text not null, value text not null,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -105,7 +105,7 @@ create table if not exists records(
create table if not exists outputgroups( create table if not exists outputgroups(
id serial not null primary key, id serial not null primary key,
name varchar(128) not null unique, name varchar(128) not null unique,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),
@ -124,7 +124,7 @@ create table if not exists outputs(
plugin varchar(20) not null, plugin varchar(20) not null,
db_uri varchar(250) not null, db_uri varchar(250) not null,
status varchar(250) not null, status varchar(250) not null,
attributes jsonb not null default '{}'::jsonb, attributes jsonb default '{}'::jsonb constraint attributes_not_null check(attributes is not null and attributes != 'null'::jsonb),
created_at timestamptz not null default now(), created_at timestamptz not null default now(),
created_by varchar(128) not null, created_by varchar(128) not null,
modified_at timestamptz not null default now(), modified_at timestamptz not null default now(),