Skip to main content

Database Structure

This Databasedatabase helps AWS Lambda to index importing tasks.

Tables

Date Indexing Table

CREATE TABLE indices.s3_date_hns (
	id bigserial NOT NULL,
	date_hns timestamp NULL,
	is_imported bool DEFAULT false NULL,
	started_at timestamp NULL,
	finished_at timestamp NULL,
	skip_flag bool DEFAULT false NULL,
	CONSTRAINT s3_date_hns_pk PRIMARY KEY (id)
);

Execution Lock Table

CREATE TABLE indices.s3_execution (
	is_executing bool DEFAULT false NULL,
	started_at timestamp NULL,
	finished_at timestamp NULL,
	last_executed_date_hns timestamp NULL,
	id serial4 NOT NULL,
	last_error varchar(255) NULL,
	CONSTRAINT s3_execution_pk PRIMARY KEY (id)
);

CSV File Importing Index

CREATE TABLE indices.s3_file_importing (
	id int4 DEFAULT nextval('indices.s3_importing_id_seq'::regclass) NOT NULL,
	date_hns timestamp NULL,
	imported_at timestamp NULL,
	filename varchar(255) NULL,
	is_successful bool DEFAULT true NULL,
	CONSTRAINT s3_importing_pk PRIMARY KEY (id)
);

Sequences

Date Indexing Sequence

CREATE SEQUENCE indices.s3_date_hns_id_seq
	INCREMENT BY 1
	MINVALUE 1
	MAXVALUE 9223372036854775807
	START 1
	CACHE 1
	NO CYCLE;

Execution Lock Sequence

CREATE SEQUENCE indices.s3_execution_id_seq
	INCREMENT BY 1
	MINVALUE 1
	MAXVALUE 2147483647
	START 1
	CACHE 1
	NO CYCLE;

CSV File Importing Sequence

CREATE SEQUENCE indices.s3_importing_id_seq
	INCREMENT BY 1
	MINVALUE 1
	MAXVALUE 2147483647
	START 1
	CACHE 1
	NO CYCLE;