-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/resource-metadata
- Loading branch information
Showing
231 changed files
with
11,452 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasTable(TableName.SshCertificateAuthority))) { | ||
await knex.schema.createTable(TableName.SshCertificateAuthority, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.timestamps(true, true, true); | ||
t.string("projectId").notNullable(); | ||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); | ||
t.string("status").notNullable(); // active / disabled | ||
t.string("friendlyName").notNullable(); | ||
t.string("keyAlgorithm").notNullable(); | ||
}); | ||
await createOnUpdateTrigger(knex, TableName.SshCertificateAuthority); | ||
} | ||
|
||
if (!(await knex.schema.hasTable(TableName.SshCertificateAuthoritySecret))) { | ||
await knex.schema.createTable(TableName.SshCertificateAuthoritySecret, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.timestamps(true, true, true); | ||
t.uuid("sshCaId").notNullable().unique(); | ||
t.foreign("sshCaId").references("id").inTable(TableName.SshCertificateAuthority).onDelete("CASCADE"); | ||
t.binary("encryptedPrivateKey").notNullable(); | ||
}); | ||
await createOnUpdateTrigger(knex, TableName.SshCertificateAuthoritySecret); | ||
} | ||
|
||
if (!(await knex.schema.hasTable(TableName.SshCertificateTemplate))) { | ||
await knex.schema.createTable(TableName.SshCertificateTemplate, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.timestamps(true, true, true); | ||
t.uuid("sshCaId").notNullable(); | ||
t.foreign("sshCaId").references("id").inTable(TableName.SshCertificateAuthority).onDelete("CASCADE"); | ||
t.string("status").notNullable(); // active / disabled | ||
t.string("name").notNullable(); | ||
t.string("ttl").notNullable(); | ||
t.string("maxTTL").notNullable(); | ||
t.specificType("allowedUsers", "text[]").notNullable(); | ||
t.specificType("allowedHosts", "text[]").notNullable(); | ||
t.boolean("allowUserCertificates").notNullable(); | ||
t.boolean("allowHostCertificates").notNullable(); | ||
t.boolean("allowCustomKeyIds").notNullable(); | ||
}); | ||
await createOnUpdateTrigger(knex, TableName.SshCertificateTemplate); | ||
} | ||
|
||
if (!(await knex.schema.hasTable(TableName.SshCertificate))) { | ||
await knex.schema.createTable(TableName.SshCertificate, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.timestamps(true, true, true); | ||
t.uuid("sshCaId").notNullable(); | ||
t.foreign("sshCaId").references("id").inTable(TableName.SshCertificateAuthority).onDelete("SET NULL"); | ||
t.uuid("sshCertificateTemplateId"); | ||
t.foreign("sshCertificateTemplateId") | ||
.references("id") | ||
.inTable(TableName.SshCertificateTemplate) | ||
.onDelete("SET NULL"); | ||
t.string("serialNumber").notNullable().unique(); | ||
t.string("certType").notNullable(); // user or host | ||
t.specificType("principals", "text[]").notNullable(); | ||
t.string("keyId").notNullable(); | ||
t.datetime("notBefore").notNullable(); | ||
t.datetime("notAfter").notNullable(); | ||
}); | ||
await createOnUpdateTrigger(knex, TableName.SshCertificate); | ||
} | ||
|
||
if (!(await knex.schema.hasTable(TableName.SshCertificateBody))) { | ||
await knex.schema.createTable(TableName.SshCertificateBody, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.timestamps(true, true, true); | ||
t.uuid("sshCertId").notNullable().unique(); | ||
t.foreign("sshCertId").references("id").inTable(TableName.SshCertificate).onDelete("CASCADE"); | ||
t.binary("encryptedCertificate").notNullable(); | ||
}); | ||
|
||
await createOnUpdateTrigger(knex, TableName.SshCertificateBody); | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.SshCertificateBody); | ||
await dropOnUpdateTrigger(knex, TableName.SshCertificateBody); | ||
|
||
await knex.schema.dropTableIfExists(TableName.SshCertificate); | ||
await dropOnUpdateTrigger(knex, TableName.SshCertificate); | ||
|
||
await knex.schema.dropTableIfExists(TableName.SshCertificateTemplate); | ||
await dropOnUpdateTrigger(knex, TableName.SshCertificateTemplate); | ||
|
||
await knex.schema.dropTableIfExists(TableName.SshCertificateAuthoritySecret); | ||
await dropOnUpdateTrigger(knex, TableName.SshCertificateAuthoritySecret); | ||
|
||
await knex.schema.dropTableIfExists(TableName.SshCertificateAuthority); | ||
await dropOnUpdateTrigger(knex, TableName.SshCertificateAuthority); | ||
} |
28 changes: 28 additions & 0 deletions
28
backend/src/db/migrations/20241218181018_app-connection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "@app/db/schemas"; | ||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "@app/db/utils"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasTable(TableName.AppConnection))) { | ||
await knex.schema.createTable(TableName.AppConnection, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
t.string("name", 32).notNullable(); | ||
t.string("description"); | ||
t.string("app").notNullable(); | ||
t.string("method").notNullable(); | ||
t.binary("encryptedCredentials").notNullable(); | ||
t.integer("version").defaultTo(1).notNullable(); | ||
t.uuid("orgId").notNullable(); | ||
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE"); | ||
t.timestamps(true, true, true); | ||
}); | ||
|
||
await createOnUpdateTrigger(knex, TableName.AppConnection); | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.AppConnection); | ||
await dropOnUpdateTrigger(knex, TableName.AppConnection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { zodBuffer } from "@app/lib/zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const AppConnectionsSchema = z.object({ | ||
id: z.string().uuid(), | ||
name: z.string(), | ||
description: z.string().nullable().optional(), | ||
app: z.string(), | ||
method: z.string(), | ||
encryptedCredentials: zodBuffer, | ||
version: z.number().default(1), | ||
orgId: z.string().uuid(), | ||
createdAt: z.date(), | ||
updatedAt: z.date() | ||
}); | ||
|
||
export type TAppConnections = z.infer<typeof AppConnectionsSchema>; | ||
export type TAppConnectionsInsert = Omit<z.input<typeof AppConnectionsSchema>, TImmutableDBKeys>; | ||
export type TAppConnectionsUpdate = Partial<Omit<z.input<typeof AppConnectionsSchema>, TImmutableDBKeys>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const SshCertificateAuthoritiesSchema = z.object({ | ||
id: z.string().uuid(), | ||
createdAt: z.date(), | ||
updatedAt: z.date(), | ||
projectId: z.string(), | ||
status: z.string(), | ||
friendlyName: z.string(), | ||
keyAlgorithm: z.string() | ||
}); | ||
|
||
export type TSshCertificateAuthorities = z.infer<typeof SshCertificateAuthoritiesSchema>; | ||
export type TSshCertificateAuthoritiesInsert = Omit<z.input<typeof SshCertificateAuthoritiesSchema>, TImmutableDBKeys>; | ||
export type TSshCertificateAuthoritiesUpdate = Partial< | ||
Omit<z.input<typeof SshCertificateAuthoritiesSchema>, TImmutableDBKeys> | ||
>; |
Oops, something went wrong.