mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 02:27:37 +00:00
Add more db models
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
import { TableName } from "../schemas";
|
||||||
|
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
|
||||||
|
|
||||||
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
// Create PkiAcmeEnrollmentConfig table
|
||||||
|
if (!(await knex.schema.hasTable(TableName.PkiAcmeEnrollmentConfig))) {
|
||||||
|
await knex.schema.createTable(TableName.PkiAcmeEnrollmentConfig, (t) => {
|
||||||
|
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||||
|
|
||||||
|
t.timestamps(true, true, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
await createOnUpdateTrigger(knex, TableName.PkiAcmeEnrollmentConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create PkiAcmeAccount table
|
||||||
|
if (!(await knex.schema.hasTable(TableName.PkiAcmeAccount))) {
|
||||||
|
await knex.schema.createTable(TableName.PkiAcmeAccount, (t) => {
|
||||||
|
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||||
|
|
||||||
|
// Foreign key to PkiCertificateProfile
|
||||||
|
t.uuid("profileId").notNullable();
|
||||||
|
t.foreign("profileId").references("id").inTable(TableName.PkiCertificateProfile).onDelete("CASCADE");
|
||||||
|
|
||||||
|
// Multi-value emails array
|
||||||
|
t.specificType("emails", "text[]").notNullable();
|
||||||
|
|
||||||
|
// Public key (PEM format)
|
||||||
|
t.text("publicKey").notNullable();
|
||||||
|
|
||||||
|
t.timestamps(true, true, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
await createOnUpdateTrigger(knex, TableName.PkiAcmeAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
// Drop PkiAcmeAccount table first (depends on PkiAcmeEnrollmentConfig)
|
||||||
|
if (await knex.schema.hasTable(TableName.PkiAcmeAccount)) {
|
||||||
|
await knex.schema.dropTable(TableName.PkiAcmeAccount);
|
||||||
|
await dropOnUpdateTrigger(knex, TableName.PkiAcmeAccount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await knex.schema.hasTable(TableName.PkiAcmeEnrollmentConfig)) {
|
||||||
|
await knex.schema.dropTable(TableName.PkiAcmeEnrollmentConfig);
|
||||||
|
await dropOnUpdateTrigger(knex, TableName.PkiAcmeEnrollmentConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,6 +92,8 @@ export * from "./pam-accounts";
|
|||||||
export * from "./pam-folders";
|
export * from "./pam-folders";
|
||||||
export * from "./pam-resources";
|
export * from "./pam-resources";
|
||||||
export * from "./pam-sessions";
|
export * from "./pam-sessions";
|
||||||
|
export * from "./pki-acme-accounts";
|
||||||
|
export * from "./pki-acme-enrollment-configs";
|
||||||
export * from "./pki-alerts";
|
export * from "./pki-alerts";
|
||||||
export * from "./pki-api-enrollment-configs";
|
export * from "./pki-api-enrollment-configs";
|
||||||
export * from "./pki-certificate-profiles";
|
export * from "./pki-certificate-profiles";
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export enum TableName {
|
|||||||
PkiEstEnrollmentConfig = "pki_est_enrollment_configs",
|
PkiEstEnrollmentConfig = "pki_est_enrollment_configs",
|
||||||
PkiApiEnrollmentConfig = "pki_api_enrollment_configs",
|
PkiApiEnrollmentConfig = "pki_api_enrollment_configs",
|
||||||
PkiAcmeEnrollmentConfig = "pki_acme_enrollment_configs",
|
PkiAcmeEnrollmentConfig = "pki_acme_enrollment_configs",
|
||||||
|
PkiAcmeAccount = "pki_acme_accounts",
|
||||||
PkiSubscriber = "pki_subscribers",
|
PkiSubscriber = "pki_subscribers",
|
||||||
PkiAlert = "pki_alerts",
|
PkiAlert = "pki_alerts",
|
||||||
PkiCollection = "pki_collections",
|
PkiCollection = "pki_collections",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// 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 PkiAcmeAccountsSchema = z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
profileId: z.string().uuid(),
|
||||||
|
emails: z.string().array(),
|
||||||
|
publicKey: z.string(),
|
||||||
|
createdAt: z.date(),
|
||||||
|
updatedAt: z.date()
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TPkiAcmeAccounts = z.infer<typeof PkiAcmeAccountsSchema>;
|
||||||
|
export type TPkiAcmeAccountsInsert = Omit<z.input<typeof PkiAcmeAccountsSchema>, TImmutableDBKeys>;
|
||||||
|
export type TPkiAcmeAccountsUpdate = Partial<Omit<z.input<typeof PkiAcmeAccountsSchema>, TImmutableDBKeys>>;
|
||||||
Reference in New Issue
Block a user