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

This commit is contained in:
Nicolas Meienberger 2023-08-15 22:55:33 +02:00 committed by Nicolas Meienberger
parent dbd616c04b
commit c83f6f57b4
2 changed files with 18 additions and 4 deletions

View file

@ -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 () => {

View file

@ -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;