mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-10-29 17:46:27 +01:00
(refs #474)Define DB and models for deploy key support
This commit is contained in:
13
src/main/resources/update/gitbucket-core_4.11.xml
Normal file
13
src/main/resources/update/gitbucket-core_4.11.xml
Normal 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>
|
||||
@@ -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")
|
||||
)
|
||||
)
|
||||
|
||||
27
src/main/scala/gitbucket/core/model/DeployKey.scala
Normal file
27
src/main/scala/gitbucket/core/model/DeployKey.scala
Normal 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
|
||||
)
|
||||
@@ -54,5 +54,6 @@ trait CoreProfile extends ProfileProvider with Profile
|
||||
with WebHookComponent
|
||||
with WebHookEventComponent
|
||||
with ProtectedBranchComponent
|
||||
with DeployKeyComponent
|
||||
|
||||
object Profile extends CoreProfile
|
||||
|
||||
Reference in New Issue
Block a user