feat: enhance database management with new migration and database node functionalities, including CRUD operations and test cases

This commit is contained in:
lborv
2025-09-27 23:41:32 +03:00
parent 0d5b2830ed
commit 785a7bfe8e
21 changed files with 333 additions and 189 deletions

View File

@ -0,0 +1,15 @@
import axios from "axios";
import { config } from "../config";
export default async (projectId: string, databaseNodeId: string) => {
try {
const response = await axios.post(`${config.url}/database/create`, {
projectId,
databaseNodeId,
});
return response.data;
} catch (error) {
console.error("Error in creating database:", error);
}
};

View File

@ -0,0 +1,22 @@
import { config } from "../config";
import axios from "axios";
export default async (
host: string,
port: number,
username: string,
password: string
) => {
try {
const response = await axios.post(`${config.url}/database/node/create`, {
host,
port,
username,
password,
});
return response.data;
} catch (error) {
console.error("Error in creating database node:", error);
}
};

View File

@ -1,12 +1,20 @@
import axios from "axios";
import { config } from "../config";
export default async (token: string, tables: any) => {
export default async (
databaseId: string,
upQuery: string,
downQuery: string
) => {
try {
const response = await axios.post(`${config.url}/migrations/create`, {
token,
tables,
});
const response = await axios.post(
`${config.url}/database/migration/create`,
{
databaseId,
up: upQuery,
down: downQuery,
}
);
return response.data;
} catch (error) {

View File

@ -0,0 +1,14 @@
import { config } from "../config";
import axios from "axios";
export default async (databaseId: string) => {
try {
const response = await axios.get(
`${config.url}/database/migration/up/${databaseId}`
);
return response.data;
} catch (error) {
console.error("Error in migrating database up:", error);
}
};