CC-5896: Store cloud files in separate table, inherited from cc_files

Using Class Table Inheritance - delegate behaviour, created a cloud_file
table to store cloud files
This commit is contained in:
drigato 2014-07-23 15:22:42 -04:00
parent 9c2a086487
commit 41ff0cce67
14 changed files with 2999 additions and 113 deletions

View file

@ -82,7 +82,6 @@
<column name="hidden" phpName="DbHidden" type="BOOLEAN" defaultValue="false"/>
<column name="is_scheduled" phpName="DbIsScheduled" type="BOOLEAN" defaultValue="false"/>
<column name="is_playlist" phpName="DbIsPlaylist" type="BOOLEAN" defaultValue="false"/>
<column name="resource_id" phpName="DbResourceId" type="LONGVARCHAR" required="false"/>
<foreign-key foreignTable="cc_subjs" phpName="FkOwner" name="cc_files_owner_fkey">
<reference local="owner_id" foreign="id"/>
</foreign-key>
@ -99,6 +98,18 @@
<index-column name="name"/>
</index>
</table>
<!-- Class Table Inheritance -->
<table name="cloud_file" phpName="CloudFile">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER"/>
<column name="resource_id" phpName="ResourceId" type="LONGVARCHAR" required="true"/>
<column name="cc_file_id" type="INTEGER"/>
<foreign-key foreignTable="cc_files">
<reference local="cc_file_id" foreign="id"/>
</foreign-key>
<behavior name="delegate">
<parameter name="to" value="cc_files"/>
</behavior>
</table>
<table name="cc_perms" phpName="CcPerms">
<column name="permid" phpName="Permid" type="INTEGER" primaryKey="true" required="true"/>
<column name="subj" phpName="Subj" type="INTEGER" required="false"/>

View file

@ -94,7 +94,6 @@ CREATE TABLE "cc_files"
"hidden" BOOLEAN DEFAULT 'f',
"is_scheduled" BOOLEAN DEFAULT 'f',
"is_playlist" BOOLEAN DEFAULT 'f',
"resource_id" TEXT,
PRIMARY KEY ("id")
);
@ -102,6 +101,20 @@ CREATE INDEX "cc_files_md5_idx" ON "cc_files" ("md5");
CREATE INDEX "cc_files_name_idx" ON "cc_files" ("name");
-----------------------------------------------------------------------
-- cloud_file
-----------------------------------------------------------------------
DROP TABLE IF EXISTS "cloud_file" CASCADE;
CREATE TABLE "cloud_file"
(
"id" serial NOT NULL,
"resource_id" TEXT NOT NULL,
"cc_file_id" INTEGER,
PRIMARY KEY ("id")
);
-----------------------------------------------------------------------
-- cc_perms
-----------------------------------------------------------------------
@ -679,6 +692,10 @@ ALTER TABLE "cc_files" ADD CONSTRAINT "cc_music_dirs_folder_fkey"
FOREIGN KEY ("directory")
REFERENCES "cc_music_dirs" ("id");
ALTER TABLE "cloud_file" ADD CONSTRAINT "cloud_file_FK_1"
FOREIGN KEY ("cc_file_id")
REFERENCES "cc_files" ("id");
ALTER TABLE "cc_perms" ADD CONSTRAINT "cc_perms_subj_fkey"
FOREIGN KEY ("subj")
REFERENCES "cc_subjs" ("id")