Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Rename table repo to repository
天舟5773e7453642
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sqlindex 4b737434a5..18ac1989be 100644--- a/store/migration/10001__init_schema.sql+++ b/store/migration/10001__init_schema.sql@@ -1036,10 +1036,10 @@ WHEREEND;--- repo table stores the repository setting for a project+-- repository table stores the repository setting for a project-- A vcs is associated with many repositories.-- A project can only link one repository (at least for now).-CREATE TABLE repo (+CREATE TABLE repository (id INTEGER PRIMARY KEY AUTOINCREMENT,row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')@@ -1064,7 +1064,7 @@ CREATE TABLE repo (-- Branch we are interested.-- For GitLab, this corresponds to webhook's push_events_branch_filter. Wildcard is supportedbranch_filter TEXT NOT NULL CHECK (trim(branch_filter) != ''),- -- Repo id from the corresponding VCS provider.+ -- Repository id from the corresponding VCS provider.-- For GitLab, this is the project id. e.g. 123external_id TEXT NOT NULL,-- Push webhook id from the corresponding VCS provider.@@ -1085,14 +1085,14 @@ CREATE TABLE repo (INSERT INTOsqlite_sequence (name, seq)VALUES- ('repo', 100);+ ('repository', 100);-CREATE TRIGGER IF NOT EXISTS `trigger_update_repo_modification_time`+CREATE TRIGGER IF NOT EXISTS `trigger_update_repository_modification_time`AFTERUPDATE- ON `repo` FOR EACH ROW BEGIN+ ON `repository` FOR EACH ROW BEGINUPDATE- `repo`+ `repository`SETupdated_ts = (strftime('%s', 'now'))WHEREdiff --git a/store/repository.go b/store/repository.goindex b5a8e016c8..2a22be6fb4 100644--- a/store/repository.go+++ b/store/repository.go@@ -141,7 +141,7 @@ func (s *RepositoryService) createRepository(ctx context.Context, tx *Tx, create// Insert row into database.row, err := tx.QueryContext(ctx, `- INSERT INTO repo (+ INSERT INTO repository (creator_id,updater_id,vcs_id,@@ -255,7 +255,7 @@ func findRepositoryList(ctx context.Context, tx *Tx, find *api.RepositoryFind) (access_token,expires_ts,refresh_token- FROM repo+ FROM repositoryWHERE `+strings.Join(where, " AND "),args...,)@@ -317,7 +317,7 @@ func patchRepository(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*// Execute update query with RETURNING.row, err := tx.QueryContext(ctx, `- UPDATE repo+ UPDATE repositorySET `+strings.Join(set, ", ")+`WHERE id = ?RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, base_directory, branch_filter, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token@@ -376,7 +376,7 @@ func (s *RepositoryService) deleteRepository(ctx context.Context, tx *Tx, delete}// Remove row from database.- result, err := tx.ExecContext(ctx, `DELETE FROM repo WHERE project_id = ?`, delete.ProjectId)+ result, err := tx.ExecContext(ctx, `DELETE FROM repository WHERE project_id = ?`, delete.ProjectId)if err != nil {return FormatError(err)}diff --git a/store/seed/test/10000__reset.sql b/store/seed/test/10000__reset.sqlindex 2eb8a24055..30ac93cc9c 100644--- a/store/seed/test/10000__reset.sql+++ b/store/seed/test/10000__reset.sql@@ -6,7 +6,7 @@ WHEREname != 'bb.auth.secret';DELETE FROM- repo;+ repository;DELETE FROMvcs;diff --git a/store/seed/test/10180__repo.sql b/store/seed/test/10180__repository.sqlsimilarity index 98%rename from store/seed/test/10180__repo.sqlrename to store/seed/test/10180__repository.sqlindex 1ef5b0c7fc..6daa7c787c 100644--- a/store/seed/test/10180__repo.sql+++ b/store/seed/test/10180__repository.sql@@ -1,6 +1,6 @@-- This is for demo purpose and the webhook has already been deletedINSERT INTO- repo (+ repository (id,creator_id,updater_id,@@ -45,7 +45,7 @@ VALUES);INSERT INTO- repo (+ repository (id,creator_id,updater_id,diff --git a/store/sqlite.go b/store/sqlite.goindex e9a07153f2..56cb1201c5 100644--- a/store/sqlite.go+++ b/store/sqlite.go@@ -349,7 +349,7 @@ func FormatError(err error) error {return common.Errorf(common.ECONFLICT, "backup name already exists")case "UNIQUE constraint failed: bookmark.creator_id, bookmark.link":return common.Errorf(common.ECONFLICT, "bookmark already exists")- case "UNIQUE constraint failed: repo.project_id":+ case "UNIQUE constraint failed: repository.project_id":return common.Errorf(common.ECONFLICT, "project has already linked repository")case "UNIQUE constraint failed: issue_subscriber.issue_id, issue_subscriber.subscriber_id":return common.Errorf(common.ECONFLICT, "issue subscriber already exists")