(refs #18)Add schema update to fix constraints for COLLABORATOR.

This commit is contained in:
takezoe
2013-07-04 18:46:01 +09:00
parent 869930165c
commit 47bdb8da23
2 changed files with 13 additions and 4 deletions

View File

@@ -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);

View File

@@ -14,7 +14,7 @@ object AutoUpdate {
* Version of GitBucket * Version of GitBucket
* *
* @param majorVersion the major version * @param majorVersion the major version
* @param minorVersion the minor version * @param minorVersion the minor version
*/ */
case class Version(majorVersion: Int, minorVersion: Int){ case class Version(majorVersion: Int, minorVersion: Int){
@@ -22,7 +22,7 @@ object AutoUpdate {
/** /**
* Execute update/MAJOR_MINOR.sql to update schema to this version. * 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 = { def update(conn: Connection): Unit = {
val sqlPath = "update/%d_%d.sql".format(majorVersion, minorVersion) val sqlPath = "update/%d_%d.sql".format(majorVersion, minorVersion)
@@ -40,7 +40,7 @@ object AutoUpdate {
} }
/** /**
* MAJOR.MINOR * MAJOR.MINOR
*/ */
val versionString = "%d.%d".format(majorVersion, minorVersion) val versionString = "%d.%d".format(majorVersion, minorVersion)
} }
@@ -49,6 +49,7 @@ object AutoUpdate {
* The history of versions. A head of this sequence is the current BitBucket version. * The history of versions. A head of this sequence is the current BitBucket version.
*/ */
val versions = Seq( val versions = Seq(
Version(1, 1),
Version(1, 0) Version(1, 0)
) )
@@ -84,7 +85,7 @@ object AutoUpdate {
} }
/** /**
* Start H2 database and update schema automatically. * Start H2 database and update schema automatically.
*/ */
class AutoUpdateListener extends org.h2.server.web.DbStarter { class AutoUpdateListener extends org.h2.server.web.DbStarter {
import AutoUpdate._ import AutoUpdate._