Skip to content

Commit

Permalink
Merge pull request #926 from thewilloftheshadow/feat/mongo-replica-sets
Browse files Browse the repository at this point in the history
feat: mongo replica sets
  • Loading branch information
Siumauricio authored Dec 26, 2024
2 parents 379ea2a + b4fcdc4 commit 8c8ffe0
Show file tree
Hide file tree
Showing 6 changed files with 4,353 additions and 6 deletions.
28 changes: 28 additions & 0 deletions apps/dokploy/components/dashboard/project/add-database.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
Expand All @@ -35,6 +36,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { slugify } from "@/lib/slug";
import { api } from "@/utils/api";
Expand Down Expand Up @@ -95,6 +97,7 @@ const mySchema = z.discriminatedUnion("type", [
.object({
type: z.literal("mongo"),
databaseUser: z.string().default("mongo"),
replicaSets: z.boolean().default(false),
})
.merge(baseDatabaseSchema),
z
Expand Down Expand Up @@ -216,6 +219,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => {
databaseUser:
data.databaseUser || databasesUserDefaultPlaceholder[data.type],
serverId: data.serverId,
replicaSets: data.replicaSets,
});
} else if (data.type === "redis") {
promise = redisMutation.mutateAsync({
Expand Down Expand Up @@ -542,6 +546,30 @@ export const AddDatabase = ({ projectId, projectName }: Props) => {
);
}}
/>

{type === "mongo" && (
<FormField
control={form.control}
name="replicaSets"
render={({ field }) => {
return (
<FormItem className="flex flex-row items-center justify-between p-3 mt-4 border rounded-lg shadow-sm">
<div className="space-y-0.5">
<FormLabel>Use Replica Sets</FormLabel>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>

<FormMessage />
</FormItem>
);
}}
/>
)}
</div>
</div>
</form>
Expand Down
1 change: 1 addition & 0 deletions apps/dokploy/drizzle/0053_broken_kulan_gath.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "mongo" ADD COLUMN "replicaSets" boolean DEFAULT false;
Loading

0 comments on commit 8c8ffe0

Please sign in to comment.