unprovision

This commit is contained in:
pavel 2026-05-15 18:41:27 +02:00
commit 1e53bba6e7
6 changed files with 148 additions and 0 deletions

View file

@ -211,6 +211,26 @@ func (a *App) reprovisionProject(ctx context.Context, userID string, projectID i
return p, nil
}
func (a *App) unprovisionProject(ctx context.Context, userID string, projectID int64) error {
p, err := a.getProject(ctx, userID, projectID)
if err != nil {
return err
}
if err := a.removeSystemdForProject(p); err != nil {
return err
}
if err := a.dropProjectDatabase(ctx, p); err != nil {
return err
}
if _, err := a.db.ExecContext(ctx, `DELETE FROM projects WHERE id=$1 AND user_id=$2`, p.ID, userID); err != nil {
return err
}
if err := a.syncCaddyConfigFragment(ctx); err != nil {
return err
}
return nil
}
func (a *App) listEnvVars(ctx context.Context, userID string, projectID int64) ([]EnvVar, error) {
if _, err := a.getProject(ctx, userID, projectID); err != nil {
return nil, err