Merge branch 'master' into 12-heuristic
# Conflicts: # build.gradlemerge-requests/8/head
commit
117315024e
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.extractor.mvc;
|
||||
package ru.ulstu.extractor.config;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.extractor.mvc;
|
||||
package ru.ulstu.extractor.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.extractor.mvc;
|
||||
package ru.ulstu.extractor.config;
|
||||
|
||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
@ -0,0 +1,69 @@
|
||||
package ru.ulstu.extractor.controller;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
import ru.ulstu.extractor.model.OffsetablePageRequest;
|
||||
import ru.ulstu.extractor.model.mvc.FilterForm;
|
||||
import ru.ulstu.extractor.service.FilteringService;
|
||||
import ru.ulstu.extractor.service.IndexService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Controller
|
||||
public class GitFilteringController {
|
||||
private final FilteringService filteringService;
|
||||
private final IndexService indexService;
|
||||
|
||||
public GitFilteringController(FilteringService filteringService,
|
||||
IndexService indexService) {
|
||||
this.filteringService = filteringService;
|
||||
this.indexService = indexService;
|
||||
}
|
||||
|
||||
/* @PostMapping("/sendFilter")
|
||||
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) throws GitAPIException, IOException {
|
||||
List<Commit> list = gitRepositoryService.getCommits(filterForm.getUrl(), filterForm.getBranch());
|
||||
model.addAttribute("commits", list);
|
||||
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
||||
model.addAttribute("error", "'Строка' не должно быть пустым");
|
||||
return "filtering";
|
||||
}
|
||||
return "resultRepo";
|
||||
}*/
|
||||
|
||||
@RequestMapping(value = "/filtering", method = RequestMethod.GET)
|
||||
public String listCommits(
|
||||
Model model,
|
||||
@ModelAttribute FilterForm filterForm,
|
||||
@RequestParam("page") Optional<Integer> page,
|
||||
@RequestParam("size") Optional<Integer> size,
|
||||
@RequestParam String repositoryUrl,
|
||||
@RequestParam String branchName) {
|
||||
int currentPage = page.orElse(1);
|
||||
int pageSize = size.orElse(5);
|
||||
|
||||
Page<Commit> commitsPage = indexService.getCommits(repositoryUrl, branchName, new OffsetablePageRequest(currentPage, pageSize));
|
||||
int totalPages = commitsPage.getTotalPages();
|
||||
if (totalPages > 0) {
|
||||
List<Integer> pageNumbers = IntStream.rangeClosed(1, totalPages)
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
model.addAttribute("pageNumbers", pageNumbers);
|
||||
}
|
||||
filterForm = new FilterForm();
|
||||
filterForm.setCommitsPage(commitsPage);
|
||||
filterForm.setBranch(branchName);
|
||||
filterForm.setUrl(repositoryUrl);
|
||||
model.addAttribute("filterForm", filterForm);
|
||||
return "filtering";
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package ru.ulstu.extractor.db;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class CommitRepository {
|
||||
private final static String SQL_SELECT_COMMITS = "SELECT * FROM commit";
|
||||
private final static String SQL_INSERT_COMMITS = "INSERT INTO commit (hash, date, author, message) " +
|
||||
"VALUES (?, ?, ?, ?)";
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public CommitRepository(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
private static class CommitRowMapper implements RowMapper<Commit> {
|
||||
|
||||
@Override
|
||||
public Commit mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return new Commit(rs.getString("message"),
|
||||
rs.getString("author"),
|
||||
rs.getDate("date"));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Commit> getCommits() {
|
||||
return jdbcTemplate.query(SQL_SELECT_COMMITS, new CommitRowMapper());
|
||||
}
|
||||
|
||||
public void saveCommit(Commit commit) {
|
||||
jdbcTemplate.update(SQL_INSERT_COMMITS, "", commit.getDate(),
|
||||
commit.getAuthor(),
|
||||
commit.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Author extends BaseEntity {
|
||||
private String name;
|
||||
|
||||
public Author() {
|
||||
}
|
||||
|
||||
public Author(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.io.Serializable;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class BaseEntity implements Serializable, Comparable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
private Integer id;
|
||||
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
public BaseEntity() {
|
||||
}
|
||||
|
||||
public BaseEntity(Integer id, Integer version) {
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!getClass().isAssignableFrom(obj.getClass())) {
|
||||
return false;
|
||||
}
|
||||
BaseEntity other = (BaseEntity) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"id=" + id +
|
||||
", version=" + version +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.id = null;
|
||||
this.version = null;
|
||||
}
|
||||
}
|
@ -1,14 +1,62 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
public class Branch {
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class Branch extends BaseEntity {
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
private Repository repository;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "branch_id", unique = true)
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<Commit> commits = new ArrayList<>();
|
||||
|
||||
public Branch() {
|
||||
}
|
||||
|
||||
public Branch(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Branch(Repository repository, String branchName) {
|
||||
this.repository = repository;
|
||||
this.name = branchName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Repository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<Commit> getCommits() {
|
||||
return commits;
|
||||
}
|
||||
|
||||
public void setCommits(List<Commit> commits) {
|
||||
this.commits = commits;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,93 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
private final int offset;
|
||||
private final int count;
|
||||
private final Sort sort;
|
||||
|
||||
public OffsetablePageRequest(int page, long pageSize) {
|
||||
this(pageSize * page, pageSize, Sort.by("id"));
|
||||
}
|
||||
|
||||
public OffsetablePageRequest(long offset, long count, Sort sort) {
|
||||
if (offset < 0) {
|
||||
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
||||
}
|
||||
if (count < 1) {
|
||||
throw new IllegalArgumentException("Count value must not be less than one!");
|
||||
}
|
||||
this.offset = (int) offset;
|
||||
this.count = (int) count;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sort getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageSize() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageNumber() {
|
||||
return offset / count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return offset > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable next() {
|
||||
return new OffsetablePageRequest(getOffset() + getPageSize(), getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable previousOrFirst() {
|
||||
return hasPrevious() ? previous() : first();
|
||||
}
|
||||
|
||||
public Pageable previous() {
|
||||
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable first() {
|
||||
return new OffsetablePageRequest(0, getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final OffsetablePageRequest other = (OffsetablePageRequest) obj;
|
||||
return this.offset == other.offset && this.count == other.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + offset;
|
||||
result = prime * result + count;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Repository extends BaseEntity {
|
||||
private String url;
|
||||
|
||||
public Repository() {
|
||||
}
|
||||
|
||||
public Repository(String repositoryUrl) {
|
||||
url = repositoryUrl;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.extractor.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.extractor.model.Author;
|
||||
import ru.ulstu.extractor.model.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthorRepository extends JpaRepository<Author, Integer> {
|
||||
@Query("SELECT a FROM Commit c, Repository r, Branch b, Author a WHERE c.author = a AND c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
|
||||
List<Author> findByRepositoryAndBranch(@Param("repository") Repository repository, @Param("branchName") String branchName);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package ru.ulstu.extractor.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.extractor.model.Branch;
|
||||
import ru.ulstu.extractor.model.Repository;
|
||||
|
||||
public interface BranchRepository extends JpaRepository<Branch, Integer> {
|
||||
Branch findByRepositoryAndName(Repository repository, String name);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.extractor.repository;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
import ru.ulstu.extractor.model.Repository;
|
||||
|
||||
public interface CommitRepository extends JpaRepository<Commit, Integer> {
|
||||
@Query("SELECT c FROM Commit c, Repository r, Branch b WHERE c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
|
||||
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package ru.ulstu.extractor.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.extractor.model.Repository;
|
||||
|
||||
public interface RepositoryRepository extends JpaRepository<Repository, Integer> {
|
||||
Repository findByUrl(String url);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package ru.ulstu.extractor.service;
|
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CommitService {
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public CommitService(GitRepositoryService gitRepositoryService) {
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
public Page<Commit> findPaginated(Pageable pageable, String repositoryUrl, String branchName) throws GitAPIException, IOException {
|
||||
int pageSize = pageable.getPageSize();
|
||||
int currentPage = pageable.getPageNumber();
|
||||
int startItem = currentPage * pageSize;
|
||||
List<Commit> commits = gitRepositoryService.getCommits(repositoryUrl, branchName);
|
||||
|
||||
if (commits.size() < startItem) {
|
||||
commits = Collections.emptyList();
|
||||
} else {
|
||||
int toIndex = Math.min(startItem + pageSize, commits.size());
|
||||
commits = commits.subList(startItem, toIndex);
|
||||
}
|
||||
return new PageImpl<>(commits, PageRequest.of(currentPage, pageSize), commits.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,32 +1,13 @@
|
||||
package ru.ulstu.extractor.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class FilteringService {
|
||||
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public FilteringService(GitRepositoryService gitRepositoryService) {
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
public List<Commit> getCommits(String urlRepo) {
|
||||
return getCommits(urlRepo, null);
|
||||
}
|
||||
private final IndexService indexService;
|
||||
|
||||
public List<Commit> getCommits(String urlRepo, String filterCommitMessage) {
|
||||
if (filterCommitMessage != null) {
|
||||
return getCommits(urlRepo)
|
||||
.stream()
|
||||
.filter(commit -> commit.getMessage().contains(filterCommitMessage))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
return getCommits(urlRepo);
|
||||
}
|
||||
public FilteringService(IndexService indexService) {
|
||||
this.indexService = indexService;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
package ru.ulstu.extractor.service;
|
||||
|
||||
import com.sun.istack.NotNull;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.model.Author;
|
||||
import ru.ulstu.extractor.model.Branch;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
import ru.ulstu.extractor.model.Repository;
|
||||
import ru.ulstu.extractor.repository.AuthorRepository;
|
||||
import ru.ulstu.extractor.repository.BranchRepository;
|
||||
import ru.ulstu.extractor.repository.CommitRepository;
|
||||
import ru.ulstu.extractor.repository.RepositoryRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class IndexService {
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
private final RepositoryRepository repositoryRepository;
|
||||
private final BranchRepository branchRepository;
|
||||
private final CommitRepository commitRepository;
|
||||
private final AuthorRepository authorRepository;
|
||||
|
||||
|
||||
public IndexService(GitRepositoryService gitRepositoryService,
|
||||
RepositoryRepository repositoryRepository,
|
||||
BranchRepository branchRepository,
|
||||
CommitRepository commitRepository,
|
||||
AuthorRepository authorRepository) {
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
this.repositoryRepository = repositoryRepository;
|
||||
this.branchRepository = branchRepository;
|
||||
this.commitRepository = commitRepository;
|
||||
this.authorRepository = authorRepository;
|
||||
}
|
||||
|
||||
public void index(@NotNull String repositoryUrl, @NotNull String branchName) throws GitAPIException, IOException {
|
||||
Repository repository = repositoryRepository.findByUrl(repositoryUrl);
|
||||
if (repository == null) {
|
||||
repositoryRepository.save(new Repository(repositoryUrl));
|
||||
}
|
||||
Branch branch = branchRepository.findByRepositoryAndName(repository, branchName);
|
||||
if (branch == null) {
|
||||
branchRepository.save(new Branch(repository, branchName));
|
||||
}
|
||||
List<Commit> commits = gitRepositoryService.getCommits(repositoryUrl, branchName);
|
||||
commitRepository.deleteAll(branch.getCommits());
|
||||
branch.getCommits().clear();
|
||||
branch.setCommits(commits);
|
||||
branchRepository.save(branch);
|
||||
gitRepositoryService.remove(repositoryUrl);
|
||||
}
|
||||
|
||||
public List<Author> getRepositoryAuthors(@NotNull String repositoryUrl, @NotNull String branchName) {
|
||||
return authorRepository.findByRepositoryAndBranch(repositoryRepository.findByUrl(repositoryUrl), branchName);
|
||||
}
|
||||
|
||||
public Page<Commit> getCommits(@NotNull String repositoryUrl, @NotNull String branchName, Pageable pageable) {
|
||||
return commitRepository.findByRepositoryAndBranch(pageable, repositoryRepository.findByUrl(repositoryUrl), branchName);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
<changeSet author="barmina" id="20210326-170000-1">
|
||||
<createTable tableName="repository">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="url" type="text"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_repository" tableName="repository"/>
|
||||
|
||||
<createTable tableName="branch">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="name" type="text"/>
|
||||
<column name="repository_id" type="integer"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_branch" tableName="branch"/>
|
||||
<addForeignKeyConstraint baseTableName="branch" baseColumnNames="repository_id" constraintName="fk_repository"
|
||||
referencedTableName="repository"
|
||||
referencedColumnNames="id"/>
|
||||
|
||||
<createTable tableName="author">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="name" type="text"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_author" tableName="author"/>
|
||||
|
||||
<createTable tableName="file_change">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="file" type="text"/>
|
||||
<column name="commit_id" type="integer"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_file_change" tableName="file_change"/>
|
||||
<addForeignKeyConstraint baseTableName="file_change" baseColumnNames="commit_id" constraintName="fk_commit"
|
||||
referencedTableName="commit"
|
||||
referencedColumnNames="id"/>
|
||||
|
||||
<createTable tableName="line_change">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="line_from" type="text"/>
|
||||
<column name="line_to" type="text"/>
|
||||
<column name="file_change_id" type="integer"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_line_change" tableName="line_change"/>
|
||||
<addForeignKeyConstraint baseTableName="line_change" baseColumnNames="file_change_id"
|
||||
constraintName="fk_file_change" referencedTableName="file_change"
|
||||
referencedColumnNames="id"/>
|
||||
|
||||
<dropColumn tableName="commit" columnName="author"/>
|
||||
<addColumn tableName="commit">
|
||||
<column name="author_id" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="commit">
|
||||
<column name="branch_id" type="integer"/>
|
||||
</addColumn>
|
||||
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="author_id" constraintName="fk_author"
|
||||
referencedTableName="author"
|
||||
referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="branch_id" constraintName="fk_branch"
|
||||
referencedTableName="branch"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
<changeSet author="orion" id="20210329-120000-1">
|
||||
<addColumn tableName="repository">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="branch">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="commit">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="author">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
<changeSet author="orion" id="20210329-120000-2">
|
||||
<addColumn tableName="file_change">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="line_change">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
<changeSet author="orion" id="20210329-120000-3" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
|
||||
<createTable tableName="hibernate_sequences">
|
||||
<column name="sequence_name" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="sequence_next_hi_value" type="BIGINT"/>
|
||||
<column name="next_val" type="bigint"/>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="sequence_name" constraintName="hibernate_sequences_pkey"
|
||||
tableName="hibernate_sequences"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
Loading…
Reference in New Issue