add unique constraints
This commit is contained in:
parent
a5a2c5e24d
commit
f1bb00ef09
@ -66,6 +66,7 @@ var (
|
|||||||
ErrCannotParseFile = errors.New("cannot parse file")
|
ErrCannotParseFile = errors.New("cannot parse file")
|
||||||
ErrValidateRecord = errors.New("error validating record")
|
ErrValidateRecord = errors.New("error validating record")
|
||||||
ErrRecordNotValid = errors.New("record not valid")
|
ErrRecordNotValid = errors.New("record not valid")
|
||||||
|
ErrRecordAlreadyExists = errors.New("record already exists")
|
||||||
ErrReadingCSVHeader = errors.New("error reading CSV header")
|
ErrReadingCSVHeader = errors.New("error reading CSV header")
|
||||||
ErrReadingCSVRow = errors.New("error reading CSV row")
|
ErrReadingCSVRow = errors.New("error reading CSV row")
|
||||||
ErrMissingOrInvalidDate = errors.New("missing or invalid date")
|
ErrMissingOrInvalidDate = errors.New("missing or invalid date")
|
||||||
|
|||||||
@ -11,7 +11,7 @@ create table public.ingest_batch
|
|||||||
id serial primary key,
|
id serial primary key,
|
||||||
|
|
||||||
elapsed_ms int not null default 0,
|
elapsed_ms int not null default 0,
|
||||||
file_checksum text not null,
|
file_checksum text not null unique,
|
||||||
|
|
||||||
created_at timestamp not null default now()
|
created_at timestamp not null default now()
|
||||||
);
|
);
|
||||||
@ -33,7 +33,9 @@ create table public.meteo_data
|
|||||||
rainfall numeric(5, 2) not null,
|
rainfall numeric(5, 2) not null,
|
||||||
cloudiness int not null,
|
cloudiness int not null,
|
||||||
|
|
||||||
created_at timestamp not null default now()
|
created_at timestamp not null default now(),
|
||||||
|
|
||||||
|
constraint uq_meteo_data_record unique (location_name_norm, date_of_register, max_temp, min_temp, rainfall, cloudiness)
|
||||||
);
|
);
|
||||||
|
|
||||||
create index idx_meteo_data_location_name_norm on public.meteo_data (location_name_norm);
|
create index idx_meteo_data_location_name_norm on public.meteo_data (location_name_norm);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user