-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
refactor(settings): migrate user settings to webServerSettings schema… #3327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Siumauricio
merged 10 commits into
canary
from
refactor/separate-settings-from-users-table
Dec 28, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
babd30a
refactor(settings): migrate user settings to webServerSettings schema…
Siumauricio b2be5bc
[autofix.ci] apply automated fixes
autofix-ci[bot] 1ccb205
fix(admin): add optional chaining to safely access settings properties
Siumauricio 6010643
refactor(server): update server configuration handling to utilize web…
Siumauricio f1dfa9c
refactor(preview-deployment): remove dynamic import of getWebServerSe…
Siumauricio 10c4f88
Update packages/server/src/services/web-server-settings.ts
Siumauricio ec56062
fix(settings): update getIp function to return an empty string for cl…
Siumauricio 3abc4cd
refactor(access-log): consolidate web server settings imports and enh…
Siumauricio b355d44
fix(web-server-settings): use optional chaining for safer ID access i…
Siumauricio 9e03625
refactor(auth): simplify trustedOrigins logic by removing redundant a…
Siumauricio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| CREATE TABLE "webServerSettings" ( | ||
| "id" text PRIMARY KEY NOT NULL, | ||
| "serverIp" text, | ||
| "certificateType" "certificateType" DEFAULT 'none' NOT NULL, | ||
| "https" boolean DEFAULT false NOT NULL, | ||
| "host" text, | ||
| "letsEncryptEmail" text, | ||
| "sshPrivateKey" text, | ||
| "enableDockerCleanup" boolean DEFAULT true NOT NULL, | ||
| "logCleanupCron" text DEFAULT '0 0 * * *', | ||
| "metricsConfig" jsonb DEFAULT '{"server":{"type":"Dokploy","refreshRate":60,"port":4500,"token":"","retentionDays":2,"cronJob":"","urlCallback":"","thresholds":{"cpu":0,"memory":0}},"containers":{"refreshRate":60,"services":{"include":[],"exclude":[]}}}'::jsonb NOT NULL, | ||
| "cleanupCacheApplications" boolean DEFAULT false NOT NULL, | ||
| "cleanupCacheOnPreviews" boolean DEFAULT false NOT NULL, | ||
| "cleanupCacheOnCompose" boolean DEFAULT false NOT NULL, | ||
| "created_at" timestamp DEFAULT now(), | ||
| "updated_at" timestamp DEFAULT now() NOT NULL | ||
| ); | ||
|
|
||
| -- Migrate data from user table to webServerSettings | ||
| -- Get the owner user's data and insert into webServerSettings | ||
| INSERT INTO "webServerSettings" ( | ||
| "id", | ||
| "serverIp", | ||
| "certificateType", | ||
| "https", | ||
| "host", | ||
| "letsEncryptEmail", | ||
| "sshPrivateKey", | ||
| "enableDockerCleanup", | ||
| "logCleanupCron", | ||
| "metricsConfig", | ||
| "cleanupCacheApplications", | ||
| "cleanupCacheOnPreviews", | ||
| "cleanupCacheOnCompose", | ||
| "created_at", | ||
| "updated_at" | ||
| ) | ||
| SELECT | ||
| gen_random_uuid()::text as "id", | ||
| u."serverIp", | ||
| COALESCE(u."certificateType", 'none') as "certificateType", | ||
| COALESCE(u."https", false) as "https", | ||
| u."host", | ||
| u."letsEncryptEmail", | ||
| u."sshPrivateKey", | ||
| COALESCE(u."enableDockerCleanup", true) as "enableDockerCleanup", | ||
| COALESCE(u."logCleanupCron", '0 0 * * *') as "logCleanupCron", | ||
| COALESCE( | ||
| u."metricsConfig", | ||
| '{"server":{"type":"Dokploy","refreshRate":60,"port":4500,"token":"","retentionDays":2,"cronJob":"","urlCallback":"","thresholds":{"cpu":0,"memory":0}},"containers":{"refreshRate":60,"services":{"include":[],"exclude":[]}}}'::jsonb | ||
| ) as "metricsConfig", | ||
| COALESCE(u."cleanupCacheApplications", false) as "cleanupCacheApplications", | ||
| COALESCE(u."cleanupCacheOnPreviews", false) as "cleanupCacheOnPreviews", | ||
| COALESCE(u."cleanupCacheOnCompose", false) as "cleanupCacheOnCompose", | ||
| NOW() as "created_at", | ||
| NOW() as "updated_at" | ||
| FROM "user" u | ||
| INNER JOIN "member" m ON u."id" = m."user_id" | ||
| WHERE m."role" = 'owner' | ||
| ORDER BY m."created_at" ASC | ||
| LIMIT 1; | ||
|
|
||
| -- If no owner found, create a default entry | ||
| INSERT INTO "webServerSettings" ( | ||
| "id", | ||
| "serverIp", | ||
| "certificateType", | ||
| "https", | ||
| "host", | ||
| "letsEncryptEmail", | ||
| "sshPrivateKey", | ||
| "enableDockerCleanup", | ||
| "logCleanupCron", | ||
| "metricsConfig", | ||
| "cleanupCacheApplications", | ||
| "cleanupCacheOnPreviews", | ||
| "cleanupCacheOnCompose", | ||
| "created_at", | ||
| "updated_at" | ||
| ) | ||
| SELECT | ||
| gen_random_uuid()::text as "id", | ||
| NULL as "serverIp", | ||
| 'none' as "certificateType", | ||
| false as "https", | ||
| NULL as "host", | ||
| NULL as "letsEncryptEmail", | ||
| NULL as "sshPrivateKey", | ||
| true as "enableDockerCleanup", | ||
| '0 0 * * *' as "logCleanupCron", | ||
| '{"server":{"type":"Dokploy","refreshRate":60,"port":4500,"token":"","retentionDays":2,"cronJob":"","urlCallback":"","thresholds":{"cpu":0,"memory":0}},"containers":{"refreshRate":60,"services":{"include":[],"exclude":[]}}}'::jsonb as "metricsConfig", | ||
| false as "cleanupCacheApplications", | ||
| false as "cleanupCacheOnPreviews", | ||
| false as "cleanupCacheOnCompose", | ||
| NOW() as "created_at", | ||
| NOW() as "updated_at" | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM "webServerSettings" | ||
| ); | ||
|
|
||
|
|
||
| --> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "serverIp";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "certificateType";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "https";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "host";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "letsEncryptEmail";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "sshPrivateKey";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "enableDockerCleanup";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "logCleanupCron";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "metricsConfig";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "cleanupCacheApplications";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "cleanupCacheOnPreviews";--> statement-breakpoint | ||
| ALTER TABLE "user" DROP COLUMN "cleanupCacheOnCompose"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using type assertion with
asbypasses TypeScript's type checking. Consider defining the proper input type or restructuring the code to avoid the type assertion.