5
home
Jamie Carl edited this page 2019-02-11 17:05:15 +11:00
Table of Contents
File Backend
This backend will work similar to the MongoDB backend and allow files to be stored in a PDO database using the Hazaar\DBI library. To use it you need to add the following two tables to your database.
File Chunks Table:
CREATE TABLE public.file_chunk
(
id serial,
parent integer,
n integer NOT NULL,
data bytea,
PRIMARY KEY (id),
FOREIGN KEY (parent)
REFERENCES public.file_chunk (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
Main file table:
CREATE TABLE public.file
(
id serial,
kind text,
parent integer,
start_chunk integer,
filename text,
created_on timestamp without time zone,
modified_on timestamp without time zone,
length integer,
mime_type text,
md5 varchar(32),
owner text ,
"group" text,
mode text,
metadata json,
PRIMARY KEY (id),
FOREIGN KEY (start_chunk)
REFERENCES public.file_chunk (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
CREATE INDEX file_md5_idx ON public.file USING btree (md5);
CREATE INDEX file_parent_idx ON public.file USING btree (parent);
CREATE INDEX file_start_chunk_idx ON public.file USING btree (start_chunk);
While I have built this to support chunks in the database, the backend itself currently only writes a single chunk. However, reads handle multiple data chunks.