Преглед изворни кода

refactor(db): merge exposed and domain with app.config

Nicolas Meienberger пре 1 година
родитељ
комит
c83f6f57b4

+ 4 - 4
src/client/modules/Apps/containers/AppDetailsContainer/AppDetailsContainer.tsx

@@ -113,8 +113,8 @@ export const AppDetailsContainer: React.FC<IProps> = ({ app }) => {
   const updateAvailable = Number(app.version || 0) < Number(app?.latestVersion || 0);
 
   const handleInstallSubmit = async (values: FormValues) => {
-    const { exposed, domain, ...form } = values;
-    install.mutate({ id: app.id, form, exposed, domain });
+    const { exposed, domain } = values;
+    install.mutate({ id: app.id, form: values, exposed, domain });
   };
 
   const handleUnistallSubmit = () => {
@@ -130,8 +130,8 @@ export const AppDetailsContainer: React.FC<IProps> = ({ app }) => {
   };
 
   const handleUpdateSettingsSubmit = async (values: FormValues) => {
-    const { exposed, domain, ...form } = values;
-    updateConfig.mutate({ id: app.id, form, exposed, domain });
+    const { exposed, domain } = values;
+    updateConfig.mutate({ id: app.id, form: values, exposed, domain });
   };
 
   const handleUpdateSubmit = async () => {

+ 14 - 0
src/server/migrations/00008-merge-config-with-domain-and-exposed.sql

@@ -0,0 +1,14 @@
+-- For all apps that have a domain or exposed field set merge those values into the config jsonb
+UPDATE
+    app
+SET
+    config = jsonb_set(config, '{domain}', to_jsonb (DOMAIN))
+WHERE
+    DOMAIN IS NOT NULL;
+
+UPDATE
+    app
+SET
+    config = jsonb_set(config, '{exposed}', to_jsonb (exposed))
+WHERE
+    exposed IS NOT NULL;