flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/services/integrations/migrations/0003_github.sql

64 lines2,258 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1-- g1t's GitHub App: installations recorded against workspaces, the
2-- repositories brought across through them, and what the app's webhook
3-- has delivered. Every timestamp is RFC 3339 UTC. See src/github.rs.
4
5-- An installation of the app on a GitHub user or organization, recorded
6-- against a workspace by one of its owners. One installation may serve
7-- several workspaces.
8CREATE TABLE github_installations (
9 -- GitHub's installation id.
10 id INTEGER NOT NULL,
11 -- The workspace's slug.
12 workspace TEXT NOT NULL,
13 -- The GitHub account's login, and User or Organization.
14 account TEXT NOT NULL,
15 account_type TEXT NOT NULL,
16 -- all or selected.
17 repository_selection TEXT NOT NULL,
18 -- Where its repositories are chosen on GitHub.
19 settings_url TEXT NOT NULL,
20 suspended_at TEXT,
21 added_by TEXT NOT NULL,
22 created_at TEXT NOT NULL,
23 PRIMARY KEY (id, workspace)
24);
25CREATE INDEX github_installations_by_workspace ON github_installations (workspace);
26
27-- A g1t repository's tie to the GitHub repository it came from.
28CREATE TABLE github_repos (
29 repo_id TEXT PRIMARY KEY,
30 workspace TEXT NOT NULL,
31 -- workspace/name on g1t.
32 repo TEXT NOT NULL,
33 installation_id INTEGER NOT NULL,
34 -- GitHub's numeric id, which survives renames and transfers.
35 github_repo_id INTEGER NOT NULL,
36 -- owner/name on GitHub, kept current by the repository webhook.
37 full_name TEXT NOT NULL,
38 -- import (copied once), mirror (g1t follows GitHub) or push (GitHub
39 -- follows g1t).
40 mode TEXT NOT NULL,
41 synced_at TEXT,
42 last_error TEXT,
43 issues_imported INTEGER NOT NULL DEFAULT 0,
44 created_by TEXT NOT NULL,
45 created_at TEXT NOT NULL
46);
47CREATE INDEX github_repos_by_github ON github_repos (github_repo_id);
48CREATE INDEX github_repos_by_workspace ON github_repos (workspace);
49
50-- Webhook deliveries seen, by X-GitHub-Delivery, so a retry is acted on
51-- once. Kept a week.
52CREATE TABLE github_deliveries (
53 id TEXT PRIMARY KEY,
54 event TEXT NOT NULL,
55 received_ms INTEGER NOT NULL
56);
57
58-- Installation access tokens, sealed under INTEGRATIONS_KEY, used until
59-- five minutes before they expire. Opaque text of any length.
60CREATE TABLE github_tokens (
61 installation_id INTEGER PRIMARY KEY,
62 token TEXT NOT NULL,
63 expires_ms INTEGER NOT NULL
64);