feat(infisical-pg): updated names and simplified dal layer using ormify

This commit is contained in:
Akhil Mohan
2024-01-27 12:38:22 +05:30
parent 15b57de0ed
commit a19e8ad016
33 changed files with 144 additions and 178 deletions
@@ -1,3 +1,4 @@
/* eslint-disable */
import { mkdirSync, writeFileSync } from "fs";
import path from "path";
import promptSync from "prompt-sync";
+1
View File
@@ -1,3 +1,4 @@
/* eslint-disable */
import { execSync } from "child_process";
import path from "path";
import promptSync from "prompt-sync";
+5 -5
View File
@@ -1,9 +1,9 @@
/* eslint-disable */
import dotenv from "dotenv";
import path from "path";
import knex from "knex";
import { appendFileSync, readFileSync, writeFileSync } from "fs";
import { writeFileSync } from "fs";
import promptSync from "prompt-sync";
import { TableName } from "@app/db/schemas";
const prompt = promptSync();
@@ -96,11 +96,11 @@ const main = async () => {
const tableNumbers =
selectedTables !== "all" ? selectedTables.split(",").map((el) => Number(el)) : [];
for (let i = 0; i < tables.length; i++) {
for (let i = 0; i < tables.length; i += 1) {
// skip if not desired table
if (selectedTables !== "all" && !tableNumbers.includes(i)) continue;
const tableName = tables[i].tableName;
const { tableName } = tables[i];
const columns = await db(tableName).columnInfo();
const columnNames = Object.keys(columns);
@@ -110,7 +110,7 @@ const main = async () => {
const colInfo = columns[columnName];
let ztype = getZodPrimitiveType(colInfo.type);
if (colInfo.defaultValue) {
const defaultValue = colInfo.defaultValue;
const { defaultValue } = colInfo;
const zSchema = getZodDefaultValue(colInfo.type, defaultValue);
if (zSchema) {
ztype = ztype.concat(zSchema);