There are a few basic things to do in order to set up and maintain a repository. To create a repository, you have to install the required DMS tables, create the file store, and assign a UUID. First you need to install the DMS schema, which is as follows:
-- Document info table CREATE TABLE doc ( fileid serial, contenttype text DEFAULT 'text/html' NOT NULL, ctime integer NOT NULL default 0, description text NOT NULL, guid text DEFAULT uuid_generate_v1() NOT NULL, hash text NOT NULL, mtime integer NOT NULL default 0, name text NOT NULL, size integer primary key (fileid) ); insert into doc(name, description, guid) values ('uuid.txt', 'uuid file', '0a92fa5e-95fa-dc11-a4fa-001ec9361a2c');
The insert statement that follows the table declaration creates the identity file entry for the repository.
Next, decide on where you want to create the file store, and create its root directory. Set the appropriate permissions, and you may also want to set the GID sticky bit is set to ensure that the permission for new files are somewhat uniform.
root #
mkdir /var/data/dmsroot #
chown -R www-data:www-data /var/data/dmsroot #
chown -R 2775 /var/data/dms
Now create the UUID file. In the database, look up the entry for the UUID file:
db=#
select fileid, guid from file;
fileid | guid
--------+---------------------------------------
1 | 0a92fa5e-95fa-dc11-a4fa-001ec9361a2c
(1 row)
The UUID file is file 1. In the root directory of the file store, create a
folder called 000
. Within in that, create a file called 001
and copy the following it.
0a92fa5e-95fa-dc11-a4fa-001ec9361a2c This is the repository UUID. The first line is all that matters. DMS will read the UUID at startup and compare it with the value in the database to ensure that database and file system match.
It doesn't matter if there is additional content in the file. DMS only reads the the first line and strips its whitespace to get the UUID. With this in place, the repository is ready to go as the database and the file store have the common UUID installed.
Use can programatically create repositories using
Respository::create()
, which takes as a single argument
the root path of the repository you want to create. It returns the UUID it used
to generate the repository ID file. Next, you need to configure the database
table. Assuming it is in exists, you will need to insert the UUID record as row
1. Using our previous podcast example, the following SQL would do that:
INSERT INTO podcast VALUES ( 1, NULL, 'text/html', NULL, NULL, false, 'repo ID', 'ccea3fda-51af-4972-96c7-349fa1f41c00', '', NULL, NULL, 'uuid.txt', NULL, NULL );