--- a/src/main/resources/db/schema-changes-0.2-0.3.sql Thu May 24 11:19:26 2012 +0200
+++ b/src/main/resources/db/schema-changes-0.2-0.3.sql Wed May 30 22:51:02 2012 +0200
@@ -41,3 +41,31 @@
alter table "service_payment" add foreign key ("period") references "code_list_item"("id");
alter table "service_payment" add foreign key ("currency") references "code_list_item"("id");
+-- attachments
+create table "attachment" (
+ "name" varchar(100) not null,
+ "updated_at" timestamp not null,
+ "id" bigint primary key not null,
+ "mime_type" varchar(80) not null,
+ "note" varchar(10240),
+ "content_id" varchar(20) not null,
+ "size" bigint not null,
+ "created_at" timestamp not null,
+ "created_by" bigint,
+ "updated_by" bigint
+ );
+create sequence "attachment_id_seq";
+create table "project_attachment" (
+ "project" bigint not null,
+ "attachment" bigint not null
+ );
+create table "task_attachment" (
+ "task" bigint not null,
+ "attachment" bigint not null
+ );
+alter table "project_attachment" add foreign key ("project") references "project"("id") on delete cascade;
+alter table "project_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade;
+alter table "task_attachment" add foreign key ("task") references "task"("id") on delete cascade;
+alter table "task_attachment" add foreign key ("attachment") references "attachment"("id") on delete cascade;
+alter table "project_attachment" add unique("project","attachment");
+alter table "task_attachment" add unique("task","attachment");