]> Some of my projects - localmylist.git/commitdiff
host_id should be an integer. Make file_location unique by fid/host/path rather than...
authorAPTX <marek321@gmail.com>
Tue, 3 Jul 2012 12:42:43 +0000 (14:42 +0200)
committerAPTX <marek321@gmail.com>
Tue, 3 Jul 2012 12:42:43 +0000 (14:42 +0200)
localmylist/share/schema/schema.sql

index ad6c855ee8452aead1d4240ef8bb07a61736b1af..e091f59b8de60e5d86abfcfd855e67c9cb707d14 100644 (file)
@@ -112,11 +112,11 @@ CREATE INDEX file_episode_rel_fid_fk ON file_episode_rel USING btree (fid);
 
 CREATE TABLE file_location (
        fid integer NOT NULL,
-       host_id character varying(100),
+       host_id integer,
        path text,
        renamed timestamp without time zone,
        failed_rename boolean NOT NULL DEFAULT false,
-       CONSTRAINT file_location_pk PRIMARY KEY (fid )
+       CONSTRAINT file_location_pk PRIMARY KEY (fid, host_id, path )
 );
 
 CREATE TABLE unknown_file (
@@ -245,7 +245,7 @@ CREATE RULE config_updated_rule AS ON UPDATE TO config DO NOTIFY config_changed;
 CREATE RULE file_episode_rel_ignore_duplicate AS ON INSERT TO file_episode_rel WHERE (EXISTS (SELECT 1 FROM file_episode_rel WHERE ((file_episode_rel.fid = new.fid) AND (file_episode_rel.eid = new.eid)))) DO INSTEAD NOTHING;
 COMMENT ON RULE file_episode_rel_ignore_duplicate ON file_episode_rel IS 'Entries to this table are duplicated in exports';
 
-CREATE RULE file_location_ignore_duplicate AS ON INSERT TO file_location WHERE (EXISTS (SELECT 1 FROM file_location WHERE (file_location.fid = new.fid))) DO INSTEAD NOTHING;
+CREATE RULE file_location_ignore_duplicate AS ON INSERT TO file_location WHERE (EXISTS (SELECT 1 FROM file_location WHERE (file_location.fid = new.fid AND file_location.host_id = new.host_id AND file_location.path = new.path))) DO INSTEAD NOTHING;
 CREATE RULE file_location_update_rule AS ON UPDATE TO file_location DO NOTIFY rename_data_changed;
 CREATE RULE new_file_location_rule AS ON INSERT TO file_location DO NOTIFY rename_data_changed;