An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: Add migration button to appwrite
Andras Bacsai8e61e9fecbdf
diff --git a/apps/api/src/lib/services/handlers.ts b/apps/api/src/lib/services/handlers.tsindex f6aaa6be5e..6f811ba831 100644--- a/apps/api/src/lib/services/handlers.ts+++ b/apps/api/src/lib/services/handlers.ts@@ -5,6 +5,7 @@ import bcrypt from 'bcryptjs';import { ServiceStartStop } from '../../routes/api/v1/services/types';import { asyncSleep, ComposeFile, createDirectories, defaultComposeConfiguration, errorHandler, executeDockerCmd, getDomain, getFreePublicPort, getServiceFromDB, getServiceImage, getServiceMainPort, isARM, isDev, makeLabelForServices, persistentVolumes, prisma } from '../common';import { defaultServiceConfigurations } from '../services';+import { OnlyId } from '../../types';export async function startService(request: FastifyRequest<ServiceStartStop>) {try {@@ -2640,3 +2641,23 @@ async function startTaigaService(request: FastifyRequest<ServiceStartStop>) {}}+export async function migrateAppwriteDB(request: FastifyRequest<OnlyId>, reply: FastifyReply) {+ try {+ const { id } = request.params+ const teamId = request.user.teamId;+ const {+ destinationDockerId,+ destinationDocker,+ } = await getServiceFromDB({ id, teamId });+ if (destinationDockerId) {+ await executeDockerCmd({+ dockerId: destinationDocker.id,+ command: `docker exec ${id} migrate`+ })+ return await reply.code(201).send()+ }+ throw { status: 500, message: 'Could cleanup logs.' }+ } catch ({ status, message }) {+ return errorHandler({ status, message })+ }+}diff --git a/apps/api/src/routes/api/v1/services/index.ts b/apps/api/src/routes/api/v1/services/index.tsindex 454f4c06e0..17ac60fdde 100644--- a/apps/api/src/routes/api/v1/services/index.ts+++ b/apps/api/src/routes/api/v1/services/index.ts@@ -30,7 +30,7 @@ import {import type { OnlyId } from '../../../../types';import type { ActivateWordpressFtp, CheckService, CheckServiceDomain, DeleteServiceSecret, DeleteServiceStorage, GetServiceLogs, SaveService, SaveServiceDestination, SaveServiceSecret, SaveServiceSettings, SaveServiceStorage, SaveServiceType, SaveServiceVersion, ServiceStartStop, SetGlitchTipSettings, SetWordpressSettings } from './types';-import { startService, stopService } from '../../../../lib/services/handlers';+import { migrateAppwriteDB, startService, stopService } from '../../../../lib/services/handlers';const root: FastifyPluginAsync = async (fastify): Promise<void> => {fastify.addHook('onRequest', async (request) => {@@ -76,6 +76,8 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {fastify.post<OnlyId>('/:id/plausibleanalytics/activate', async (request, reply) => await activatePlausibleUsers(request, reply));fastify.post<OnlyId>('/:id/plausibleanalytics/cleanup', async (request, reply) => await cleanupPlausibleLogs(request, reply));fastify.post<ActivateWordpressFtp>('/:id/wordpress/ftp', async (request, reply) => await activateWordpressFtp(request, reply));++ fastify.post<OnlyId>('/:id/appwrite/migrate', async (request, reply) => await migrateAppwriteDB(request, reply));};export default root;diff --git a/apps/ui/src/lib/components/DocLink.svelte b/apps/ui/src/lib/components/DocLink.svelteindex 39c8302c8c..d561566f03 100644--- a/apps/ui/src/lib/components/DocLink.svelte+++ b/apps/ui/src/lib/components/DocLink.svelte@@ -11,22 +11,9 @@</script><a {id} href={url} target="_blank" class="icons inline-block cursor-pointer text-xs mx-2">- <svg- xmlns="http://www.w3.org/2000/svg"- class="w-6 h-6"- viewBox="0 0 24 24"- stroke-width="1.5"- stroke="currentColor"- fill="none"- stroke-linecap="round"- stroke-linejoin="round"- >- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path- d="M6 4h11a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-11a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1m3 0v18"- />- <line x1="13" y1="8" x2="15" y2="8" />- <line x1="13" y1="12" x2="15" y2="12" />- </svg>+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z" />+ </svg>+</a><Tooltip triggeredBy={`#${id}`}>See details in the documentation</Tooltip>diff --git a/apps/ui/src/routes/services/[id]/_Services/_Services.svelte b/apps/ui/src/routes/services/[id]/_Services/_Services.svelteindex 60f080e7e2..3a1dabcb7f 100644--- a/apps/ui/src/routes/services/[id]/_Services/_Services.svelte+++ b/apps/ui/src/routes/services/[id]/_Services/_Services.svelte@@ -39,6 +39,7 @@import Weblate from './_Weblate.svelte';import Explainer from '$lib/components/Explainer.svelte';import Taiga from './_Taiga.svelte';+ import DocLink from '$lib/components/DocLink.svelte';const { id } = $page.params;$: isDisabled =@@ -126,6 +127,20 @@loading.verification = false;}}+ async function migrateAppwriteDB() {+ loading.verification = true;+ try {+ await post(`/services/${id}/${service.type}/migrate`, { id: service.id });+ return addToast({+ message: "Appwrite's database has been migrated.",+ type: 'success'+ });+ } catch (error) {+ return errorNotification(error);+ } finally {+ loading.verification = false;+ }+ }async function changeSettings(name: any) {try {if (name === 'dualCerts') {@@ -154,6 +169,9 @@loading.cleanup = false;}}+ function doNothing() {+ return;+ }onMount(async () => {if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {service.fqdn = `http://${cuid()}.demo.coolify.io`;@@ -182,7 +200,7 @@<form on:submit|preventDefault={handleSubmit} class="py-4"><div class="flex space-x-1 pb-5 items-center"><h1 class="title">{$t('general')}</h1>- <div class="flex flex-row space-y-3 items-center">+ <div class="flex flex-row space-x-2 items-center">{#if $appSession.isAdmin}<buttontype="submit"@@ -200,21 +218,35 @@>{/if}{#if service.type === 'plausibleanalytics' && $status.service.isRunning}+ <div class="btn-group">+ <button+ class="btn btn-sm"+ on:click|preventDefault={setEmailsToVerified}+ disabled={loading.verification}+ class:loading={loading.verification}+ >{loading.verification+ ? $t('forms.verifying')+ : $t('forms.verify_emails_without_smtp')}</button+ >+ <button+ class="btn btn-sm"+ on:click|preventDefault={cleanupLogs}+ disabled={loading.cleanup}+ class:loading={loading.cleanup}>Cleanup Unnecessary Database Logs</button+ >+ </div>+ {/if}+ {#if service.type === 'appwrite' && $status.service.isRunning}<buttonclass="btn btn-sm"- on:click|preventDefault={setEmailsToVerified}+ on:click|preventDefault={migrateAppwriteDB}disabled={loading.verification}class:loading={loading.verification}>{loading.verification- ? $t('forms.verifying')- : $t('forms.verify_emails_without_smtp')}</button- >- <button- class="btn btn-sm"- on:click|preventDefault={cleanupLogs}- disabled={loading.cleanup}- class:loading={loading.cleanup}>Cleanup Unnecessary Database Logs</button+ ? 'Migrating... it may take a while...'+ : "Migrate Appwrite's Database"}</button>+ <DocLink url="https://appwrite.io/docs/upgrade#run-the-migration" />{/if}</div></div>