From 370a90bb2308c755b037f0e75eb347515cdb083d Mon Sep 17 00:00:00 2001 From: mustafa_98 Date: Fri, 16 Jan 2026 23:06:02 +0000 Subject: [PATCH] =?UTF-8?q?=D8=AD=D8=B0=D9=81=20PostgreSQLPostgreSQLMigrat?= =?UTF-8?q?or.jsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PostgreSQLPostgreSQLMigrator.jsx | 208 ------------------------------- 1 file changed, 208 deletions(-) delete mode 100644 PostgreSQLPostgreSQLMigrator.jsx diff --git a/PostgreSQLPostgreSQLMigrator.jsx b/PostgreSQLPostgreSQLMigrator.jsx deleted file mode 100644 index 53b5671..0000000 --- a/PostgreSQLPostgreSQLMigrator.jsx +++ /dev/null @@ -1,208 +0,0 @@ -import { useState } from "react"; -import { getSchemas, getTables, startMigration, getProgress } from "../api"; - -export default function PostgreSQLPostgreSQLMigrator() { - const [srcHost, setSrcHost] = useState(""); - const [srcUser, setSrcUser] = useState(""); - const [srcPass, setSrcPass] = useState(""); - const [schemas, setSchemas] = useState([]); - const [selectedSchemas, setSelectedSchemas] = useState([]); - const [destHost, setDestHost] = useState(""); - const [destUser, setDestUser] = useState(""); - const [destPass, setDestPass] = useState(""); - const [progress, setProgress] = useState({ percent: 0, message: "Waiting to start..." }); - const [loading, setLoading] = useState(false); - - const loadSchemas = async () => { - setLoading(true); - try { - const data = await getSchemas("psql_psql", { host: srcHost, user: srcUser, pass: srcPass }); - setSchemas(data.schemas || []); - if (data.error) { - alert("Error loading schemas: " + data.error); - } - } catch { - setSchemas([]); - } finally { - setLoading(false); - } - }; - - const handleMigration = async () => { - const payload = { - DB_HOST: srcHost, - DB_USER: srcUser, - DB_PASS: srcPass, - DB_NAME: selectedSchemas[0] || "", - DEST_HOST: destHost, - DEST_USER: destUser, - DEST_PASS: destPass, - DEST_NAME: selectedSchemas[0] || "", - ONLY_SCHEMAS: selectedSchemas.join(",") - }; - try { - const data = await startMigration("psql_psql", payload); - if (data.success) { - pollProgress(); - } else { - alert("Migration failed: " + (data.error || "Unknown error")); - } - } catch (error) { - console.error("Error starting migration:", error); - alert("Connection error: " + error.message); - } - }; - - const pollProgress = async () => { - try { - const data = await getProgress("psql_psql"); - setProgress(data); - if (data.status === "error") { - alert("Migration error: " + (data.message || "Unknown error")); - } else if (data.percent < 100 && data.status !== "completed") { - setTimeout(pollProgress, 2000); - } - } catch (error) { - console.error("Error polling progress:", error); - setTimeout(pollProgress, 2000); - } - }; - - return ( -
-
-

- PostgreSQL → PostgreSQL Migration -

-

- Migrate PostgreSQL schemas and tables. -

-
- -
- {/* Source Database */} -
-

- Source Database -

-
-
- - setSrcHost(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
-
- - setSrcUser(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
-
- - setSrcPass(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
- - {schemas.length > 0 && ( -
- - -
- )} -
-
- - {/* Target Database */} -
-

- Target Database -

-
-
- - setDestHost(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
-
- - setDestUser(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
-
- - setDestPass(e.target.value)} - className="w-full px-4 py-3 border border-gray-300 dark:border-red-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-all duration-200 placeholder-gray-400 dark:placeholder-gray-500" - /> -
-
-
-
- - {/* Migration Button */} -
- -
- - {/* Progress */} -
-

Progress

-
-
-
-
-          {JSON.stringify(progress, null, 2)}
-        
-
-
- ); -} \ No newline at end of file