diff --git a/src/main/resources/update/1_1.sql b/src/main/resources/update/1_1.sql new file mode 100644 index 0000000..9cfd50a --- /dev/null +++ b/src/main/resources/update/1_1.sql @@ -0,0 +1,8 @@ +-- Fix COLLABORATOR constraints +ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_FK1 IF EXISTS; +ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_FK0 IF EXISTS; +ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_PK IF EXISTS; + +ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, COLLABORATOR_NAME); +ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME); +ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK1 FOREIGN KEY (COLLABORATOR_NAME) REFERENCES ACCOUNT (USER_NAME); diff --git a/src/main/scala/servlet/AutoUpdateListener.scala b/src/main/scala/servlet/AutoUpdateListener.scala index aa48a00..5453c22 100644 --- a/src/main/scala/servlet/AutoUpdateListener.scala +++ b/src/main/scala/servlet/AutoUpdateListener.scala @@ -14,7 +14,7 @@ * Version of GitBucket * * @param majorVersion the major version - * @param minorVersion the minor version + * @param minorVersion the minor version */ case class Version(majorVersion: Int, minorVersion: Int){ @@ -22,7 +22,7 @@ /** * Execute update/MAJOR_MINOR.sql to update schema to this version. - * If corresponding SQL file does not exist, this method do nothing. + * If corresponding SQL file does not exist, this method do nothing. */ def update(conn: Connection): Unit = { val sqlPath = "update/%d_%d.sql".format(majorVersion, minorVersion) @@ -40,7 +40,7 @@ } /** - * MAJOR.MINOR + * MAJOR.MINOR */ val versionString = "%d.%d".format(majorVersion, minorVersion) } @@ -49,6 +49,7 @@ * The history of versions. A head of this sequence is the current BitBucket version. */ val versions = Seq( + Version(1, 1), Version(1, 0) ) @@ -84,7 +85,7 @@ } /** - * Start H2 database and update schema automatically. + * Start H2 database and update schema automatically. */ class AutoUpdateListener extends org.h2.server.web.DbStarter { import AutoUpdate._