Rename table RELEASE to RELEASE_TAG

This commit is contained in:
Naoki Takezoe
2018-03-18 13:50:30 +09:00
parent b89c99d388
commit d8e5a89ac5
9 changed files with 27 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<createTable tableName="RELEASE">
<createTable tableName="RELEASE_TAG">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
<column name="TAG" type="varchar(100)" nullable="false"/>
@@ -11,8 +11,8 @@
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
</createTable>
<addPrimaryKey constraintName="IDX_RELEASE_PK" tableName="RELEASE" columnNames="USER_NAME, REPOSITORY_NAME, TAG"/>
<addForeignKeyConstraint constraintName="IDX_RELEASE_FK0" baseTableName="RELEASE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
<addPrimaryKey constraintName="IDX_RELEASE_TAG_PK" tableName="RELEASE_TAG" columnNames="USER_NAME, REPOSITORY_NAME, TAG"/>
<addForeignKeyConstraint constraintName="IDX_RELEASE_TAG_FK0" baseTableName="RELEASE_TAG" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
<createTable tableName="RELEASE_ASSET">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
@@ -27,7 +27,7 @@
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
</createTable>
<addPrimaryKey constraintName="IDX_RELEASE_ASSET_PK" tableName="RELEASE_ASSET" columnNames="USER_NAME, REPOSITORY_NAME, TAG, FILE_NAME"/>
<addForeignKeyConstraint constraintName="IDX_RELEASE_ASSET_FK1" baseTableName="RELEASE_ASSET" baseColumnNames="USER_NAME, REPOSITORY_NAME, TAG" referencedTableName="RELEASE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, TAG"/>
<addForeignKeyConstraint constraintName="IDX_RELEASE_ASSET_FK1" baseTableName="RELEASE_ASSET" baseColumnNames="USER_NAME, REPOSITORY_NAME, TAG" referencedTableName="RELEASE_TAG" referencedColumnNames="USER_NAME, REPOSITORY_NAME, TAG"/>
<createTable tableName="ACCOUNT_FEDERATION">
<column name="ISSUER" type="varchar(100)" nullable="false"/>

View File

@@ -64,7 +64,7 @@ trait CoreProfile extends ProfileProvider with Profile
with AccountFederationComponent
with ProtectedBranchComponent
with DeployKeyComponent
with ReleaseComponent
with ReleaseTagComponent
with ReleaseAssetComponent
object Profile extends CoreProfile

View File

@@ -1,14 +1,14 @@
package gitbucket.core.model
trait ReleaseComponent extends TemplateComponent {
trait ReleaseTagComponent extends TemplateComponent {
self: Profile =>
import profile.api._
import self._
lazy val Releases = TableQuery[Releases]
lazy val ReleaseTags = TableQuery[ReleaseTags]
class Releases(tag_ : Tag) extends Table[Release](tag_, "RELEASE") with BasicTemplate {
class ReleaseTags(tag_ : Tag) extends Table[ReleaseTag](tag_, "RELEASE_TAG") with BasicTemplate {
val name = column[String]("NAME")
val tag = column[String]("TAG")
val author = column[String]("AUTHOR")
@@ -16,13 +16,13 @@ trait ReleaseComponent extends TemplateComponent {
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
val updatedDate = column[java.util.Date]("UPDATED_DATE")
def * = (userName, repositoryName, name, tag, author, content, registeredDate, updatedDate) <> (Release.tupled, Release.unapply)
def * = (userName, repositoryName, name, tag, author, content, registeredDate, updatedDate) <> (ReleaseTag.tupled, ReleaseTag.unapply)
def byPrimaryKey(owner: String, repository: String, tag: String) = byTag(owner, repository, tag)
def byTag(owner: String, repository: String, tag: String) = byRepository(owner, repository) && (this.tag === tag.bind)
}
}
case class Release(
case class ReleaseTag(
userName: String,
repositoryName: String,
name: String,

View File

@@ -1,7 +1,7 @@
package gitbucket.core.service
import gitbucket.core.controller.Context
import gitbucket.core.model.{Account, Release, ReleaseAsset}
import gitbucket.core.model.{Account, ReleaseTag, ReleaseAsset}
import gitbucket.core.model.Profile.profile.blockingApi._
import gitbucket.core.model.Profile._
import gitbucket.core.model.Profile.dateColumnType
@@ -27,7 +27,7 @@ trait ReleaseService {
ReleaseAssets.filter(x => x.byTag(owner, repository, tag)).list
}
def getReleaseAssetsMap(owner: String, repository: String)(implicit s: Session): Map[Release, Seq[ReleaseAsset]] = {
def getReleaseAssetsMap(owner: String, repository: String)(implicit s: Session): Map[ReleaseTag, Seq[ReleaseAsset]] = {
val releases = getReleases(owner, repository)
releases.map(rel => (rel -> getReleaseAssets(owner, repository, rel.tag))).toMap
}
@@ -42,7 +42,7 @@ trait ReleaseService {
def createRelease(owner: String, repository: String, name: String, content: Option[String], tag: String,
loginAccount: Account)(implicit context: Context, s: Session): Int = {
Releases insert Release(
ReleaseTags insert ReleaseTag(
userName = owner,
repositoryName = repository,
name = name,
@@ -54,13 +54,13 @@ trait ReleaseService {
)
}
def getReleases(owner: String, repository: String)(implicit s: Session): Seq[Release] = {
Releases.filter(x => x.byRepository(owner, repository)).list
def getReleases(owner: String, repository: String)(implicit s: Session): Seq[ReleaseTag] = {
ReleaseTags.filter(x => x.byRepository(owner, repository)).list
}
def getRelease(owner: String, repository: String, tag: String)(implicit s: Session): Option[Release] = {
def getRelease(owner: String, repository: String, tag: String)(implicit s: Session): Option[ReleaseTag] = {
//Releases filter (_.byPrimaryKey(owner, repository, releaseId)) firstOption
Releases filter (_.byTag(owner, repository, tag)) firstOption
ReleaseTags filter (_.byTag(owner, repository, tag)) firstOption
}
// def getReleaseByTag(owner: String, repository: String, tag: String)(implicit s: Session): Option[Release] = {
@@ -74,7 +74,7 @@ trait ReleaseService {
// }
def updateRelease(owner: String, repository: String, tag: String, title: String, content: Option[String])(implicit s: Session): Int = {
Releases
ReleaseTags
.filter (_.byPrimaryKey(owner, repository, tag))
.map { t => (t.name, t.content, t.updatedDate) }
.update (title, content, currentDate)
@@ -82,6 +82,6 @@ trait ReleaseService {
def deleteRelease(owner: String, repository: String, tag: String)(implicit s: Session): Unit = {
deleteReleaseAssets(owner, repository, tag)
Releases filter (_.byPrimaryKey(owner, repository, tag)) delete
ReleaseTags filter (_.byPrimaryKey(owner, repository, tag)) delete
}
}

View File

@@ -3,7 +3,7 @@ package gitbucket.core.service
import gitbucket.core.controller.Context
import gitbucket.core.util._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.model.{Account, Collaborator, Repository, RepositoryOptions, Role, Release}
import gitbucket.core.model.{Account, Collaborator, Repository, RepositoryOptions, Role, ReleaseTag}
import gitbucket.core.model.Profile._
import gitbucket.core.model.Profile.profile.blockingApi._
import gitbucket.core.model.Profile.dateColumnType
@@ -77,7 +77,7 @@ trait RepositoryService { self: AccountService =>
val protectedBranches = ProtectedBranches .filter(_.byRepository(oldUserName, oldRepositoryName)).list
val protectedBranchContexts = ProtectedBranchContexts.filter(_.byRepository(oldUserName, oldRepositoryName)).list
val deployKeys = DeployKeys .filter(_.byRepository(oldUserName, oldRepositoryName)).list
val releases = Releases .filter(_.byRepository(oldUserName, oldRepositoryName)).list
val releases = ReleaseTags .filter(_.byRepository(oldUserName, oldRepositoryName)).list
val releaseAssets = ReleaseAssets .filter(_.byRepository(oldUserName, oldRepositoryName)).list
Repositories.filter { t =>
@@ -124,7 +124,7 @@ trait RepositoryService { self: AccountService =>
ProtectedBranches .insertAll(protectedBranches.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
ProtectedBranchContexts.insertAll(protectedBranchContexts.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
DeployKeys .insertAll(deployKeys .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
Releases .insertAll(releases .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
ReleaseTags .insertAll(releases .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
ReleaseAssets .insertAll(releaseAssets .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
// Update source repository of pull requests
@@ -179,8 +179,8 @@ trait RepositoryService { self: AccountService =>
RepositoryWebHooks .filter(_.byRepository(userName, repositoryName)).delete
RepositoryWebHookEvents .filter(_.byRepository(userName, repositoryName)).delete
DeployKeys .filter(_.byRepository(userName, repositoryName)).delete
ReleaseAssets .filter(_.byRepository(userName, repositoryName)).delete
Releases .filter(_.byRepository(userName, repositoryName)).delete
ReleaseAssets .filter(_.byRepository(userName, repositoryName)).delete
ReleaseTags .filter(_.byRepository(userName, repositoryName)).delete
Repositories .filter(_.byRepository(userName, repositoryName)).delete
// Update ORIGIN_USER_NAME and ORIGIN_REPOSITORY_NAME

View File

@@ -1,6 +1,6 @@
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
tag: gitbucket.core.util.JGitUtil.TagInfo,
release: Option[(gitbucket.core.model.Release, Seq[gitbucket.core.model.ReleaseAsset])])(implicit context: gitbucket.core.controller.Context)
release: Option[(gitbucket.core.model.ReleaseTag, Seq[gitbucket.core.model.ReleaseAsset])])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"New Release - ${repository.owner}/${repository.name}", Some(repository)){
@gitbucket.core.html.menu("releases", repository){

View File

@@ -1,5 +1,5 @@
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
releases: Seq[(gitbucket.core.util.JGitUtil.TagInfo, Option[(gitbucket.core.model.Release, Seq[gitbucket.core.model.ReleaseAsset])])],
releases: Seq[(gitbucket.core.util.JGitUtil.TagInfo, Option[(gitbucket.core.model.ReleaseTag, Seq[gitbucket.core.model.ReleaseAsset])])],
hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main("Releases" + s" - ${repository.owner}/${repository.name}", Some(repository)){

View File

@@ -1,4 +1,4 @@
@(release: gitbucket.core.model.Release,
@(release: gitbucket.core.model.ReleaseTag,
assets: Seq[gitbucket.core.model.ReleaseAsset],
hasWritePermission: Boolean,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)