# public.git_connection

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| baseCommit | varchar(64) |  | true |  |  | Last commit successfully reconciled for this connection; the base for three-way reconciliation. |
| branchName | varchar(255) |  | true |  |  |  |
| connectionType | varchar(16) |  | false |  |  | GitConnectionType enum: "ssh", "https" |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| encryptedPassword | text |  | true |  |  | Encrypted HTTPS password/token; set when connectionType is 'https', null for 'ssh'. |
| encryptedPrivateKey | text |  | true |  |  | Encrypted SSH private key; set when connectionType is 'ssh', null for 'https'. |
| encryptedUsername | text |  | true |  |  | Encrypted HTTPS username; set when connectionType is 'https', null for 'ssh'. |
| id | varchar(36) |  | false | [public.git_connection_project](public.git_connection_project.md) |  |  |
| keyGeneratorType | varchar(16) |  | true |  |  | GitKeyGeneratorType enum: "ed25519", "rsa" |
| name | varchar(128) |  | false |  |  |  |
| publicKey | text |  | true |  |  | SSH public key; set when connectionType is 'ssh', null for 'https'. |
| repositoryUrl | text |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_git_connection_connectionType | CHECK | CHECK ((("connectionType")::text = ANY ((ARRAY['ssh'::character varying, 'https'::character varying])::text[]))) |
| CHK_git_connection_https_auth | CHECK | CHECK (((("connectionType")::text <> 'https'::text) OR (("publicKey" IS NULL) AND ("encryptedPrivateKey" IS NULL) AND ("keyGeneratorType" IS NULL)))) |
| CHK_git_connection_keyGeneratorType | CHECK | CHECK ((("keyGeneratorType")::text = ANY ((ARRAY['ed25519'::character varying, 'rsa'::character varying])::text[]))) |
| CHK_git_connection_ssh_auth | CHECK | CHECK (((("connectionType")::text <> 'ssh'::text) OR (("encryptedUsername" IS NULL) AND ("encryptedPassword" IS NULL)))) |
| PK_92966b7ba4ce2cf61a62017a6ff | PRIMARY KEY | PRIMARY KEY (id) |
| git_connection_connectionType_not_null | n | NOT NULL "connectionType" |
| git_connection_createdAt_not_null | n | NOT NULL "createdAt" |
| git_connection_id_not_null | n | NOT NULL id |
| git_connection_name_not_null | n | NOT NULL name |
| git_connection_repositoryUrl_not_null | n | NOT NULL "repositoryUrl" |
| git_connection_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_92966b7ba4ce2cf61a62017a6ff | CREATE UNIQUE INDEX "PK_92966b7ba4ce2cf61a62017a6ff" ON public.git_connection USING btree (id) |

## Relations

```mermaid
erDiagram

"public.git_connection_project" }o--|| "public.git_connection" : "FOREIGN KEY (#quot;gitConnectionId#quot;) REFERENCES git_connection(id) ON DELETE CASCADE"

"public.git_connection" {
  varchar_64_ baseCommit
  varchar_255_ branchName
  varchar_16_ connectionType
  timestamp_3__with_time_zone createdAt
  text encryptedPassword
  text encryptedPrivateKey
  text encryptedUsername
  varchar_36_ id
  varchar_16_ keyGeneratorType
  varchar_128_ name
  text publicKey
  text repositoryUrl
  timestamp_3__with_time_zone updatedAt
}
"public.git_connection_project" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ gitConnectionId FK
  varchar_36_ projectId FK
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)
