(refs #474)Define DB and models for deploy key support

This commit is contained in:
Naoki Takezoe
2017-03-02 16:48:54 +09:00
parent b6390ac383
commit 42d3585df5
4 changed files with 45 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<createTable tableName="DEPLOY_KEY">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
<column name="DEPLOY_KEY_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
<column name="TITLE" type="varchar(100)" nullable="false"/>
<column name="PUBLIC_KEY" type="text" nullable="false"/>
</createTable>
<addPrimaryKey constraintName="IDX_DEPLOY_KEY_PK" tableName="DEPLOY_KEY" columnNames="USER_NAME, REPOSITORY_NAME, DEPLOY_KEY_ID"/>
<addForeignKeyConstraint constraintName="IDX_DEPLOY_KEY_FK0" baseTableName="DEPLOY_KEY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
</changeSet>

View File

@@ -28,5 +28,8 @@ object GitBucketCoreModule extends Module("gitbucket-core",
new Version("4.9.0",
new LiquibaseMigration("update/gitbucket-core_4.9.xml")
),
new Version("4.10.0")
new Version("4.10.0"),
new Version("4.11.0",
new LiquibaseMigration("update/gitbucket-core_4.11.xml")
)
)

View File

@@ -0,0 +1,27 @@
package gitbucket.core.model
trait DeployKeyComponent { self: Profile =>
import profile.api._
lazy val DeployKeys = TableQuery[DeployKeys]
class DeployKeys(tag: Tag) extends Table[DeployKey](tag, "DEPLOY_KEY") {
val userName = column[String]("USER_NAME")
val repositoryName = column[String]("REPOSITORY_NAME")
val deployKeyId = column[Int]("DEPLOY_KEY_ID", O AutoInc)
val title = column[String]("TITLE")
val publicKey = column[String]("PUBLIC_KEY")
def * = (userName, repositoryName, deployKeyId, title, publicKey) <> (DeployKey.tupled, DeployKey.unapply)
def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) =
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind)
}
}
case class DeployKey(
userName: String,
repositoryName: String,
deployKeyId: Int = 0,
title: String,
publicKey: String
)

View File

@@ -54,5 +54,6 @@ trait CoreProfile extends ProfileProvider with Profile
with WebHookComponent
with WebHookEventComponent
with ProtectedBranchComponent
with DeployKeyComponent
object Profile extends CoreProfile