Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Create repo table
天舟948d65c54ca5
diff --git a/backend/store/migration/0001_init_schema.down.sql b/backend/store/migration/0001_init_schema.down.sqlindex 98f118e364..b352fb27e9 100644--- a/backend/store/migration/0001_init_schema.down.sql+++ b/backend/store/migration/0001_init_schema.down.sql@@ -1,3 +1,5 @@+DROP TABLE repo;+DROP TABLE vcs;DROP TABLE bookmark;diff --git a/backend/store/migration/0001_init_schema.up.sql b/backend/store/migration/0001_init_schema.up.sqlindex b854f82d28..a051e971a8 100644--- a/backend/store/migration/0001_init_schema.up.sql+++ b/backend/store/migration/0001_init_schema.up.sql@@ -675,4 +675,47 @@ SETWHERErowid = old.rowid;+END;++-- repo 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 (+ id INTEGER PRIMARY KEY AUTOINCREMENT,+ row_status TEXT NOT NULL CHECK (+ row_status IN ('NORMAL', 'ARCHIVED', 'PENDING_DELETE')+ ) DEFAULT 'NORMAL',+ creator_id INTEGER NOT NULL REFERENCES principal (id),+ created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ updater_id INTEGER NOT NULL REFERENCES principal (id),+ updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ vcs_id INTEGER NOT NULL REFERENCES vcs (id),+ project_id INTEGER NOT NULL UNIQUE REFERENCES project (id),+ -- Repo id for the corresponding VCS provider. For GitLab, this is the GitLab project id+ external_id TEXT NOT NULL,+ -- Push webhook id for the corresponding VCS provider.+ webhook_id TEXT NOT NULL,+ name TEXT NOT NULL,+ full_path TEXT NOT NULL,+ web_url TEXT NOT NULL,+ base_directory TEXT NOT NULL DEFAULT '',+ branch_filter TEXT NOT NULL DEFAULT ''+);++INSERT INTO+ sqlite_sequence (name, seq)+VALUES+ ('repo', 1000);++CREATE TRIGGER IF NOT EXISTS `trigger_update_repo_modification_time`+AFTER+UPDATE+ ON `repo` FOR EACH ROW BEGIN+UPDATE+ `repo`+SET+ updated_ts = (strftime('%s', 'now'))+WHERE+ rowid = old.rowid;+END;\ No newline at end of filediff --git a/backend/store/seed/0170_repo.sql b/backend/store/seed/0170_repo.sqlnew file mode 100644index 0000000000..8a0ee87660--- /dev/null+++ b/backend/store/seed/0170_repo.sql@@ -0,0 +1,28 @@+INSERT INTO+ repo (+ id,+ creator_id,+ updater_id,+ vcs_id,+ project_id,+ external_id,+ webhook_id,+ name,+ full_path,+ web_url+ )+VALUES+ (+ 17001,+ 1001,+ 1001,+ 16001,+ 3001,+ -- Refers to the bytebase-test/project1+ "7",+ -- Refers to the webhook in bytebase-test/project1+ "5",+ "project1",+ "bytebase-test/project1",+ "http://gitlab.bytebase.com/bytebase-test/project1"+ );\ No newline at end of file