Merge branch 'dev' of https://github.com/fosrl/pangolin into dev

This commit is contained in:
Milo Schwartz 2025-01-25 13:23:46 -05:00
commit 641b65cfab
2 changed files with 53 additions and 33 deletions

View file

@ -438,29 +438,53 @@ func isDockerInstalled() bool {
return true return true
} }
func getCommandString(useNewStyle bool) string {
if useNewStyle {
return "'docker compose'"
}
return "'docker-compose'"
}
func pullAndStartContainers() error { func pullAndStartContainers() error {
fmt.Println("Starting containers...") fmt.Println("Starting containers...")
// First try docker compose (new style) // Check which docker compose command is available
cmd := exec.Command("docker", "compose", "-f", "docker-compose.yml", "pull") var useNewStyle bool
cmd.Stdout = os.Stdout checkCmd := exec.Command("docker", "compose", "version")
cmd.Stderr = os.Stderr if err := checkCmd.Run(); err == nil {
err := cmd.Run() useNewStyle = true
} else {
if err != nil { // Check if docker-compose (old style) is available
fmt.Println("Failed to start containers using docker compose, falling back to docker-compose command") checkCmd = exec.Command("docker-compose", "version")
os.Exit(1) if err := checkCmd.Run(); err != nil {
return fmt.Errorf("neither 'docker compose' nor 'docker-compose' command is available: %v", err)
}
} }
cmd = exec.Command("docker", "compose", "-f", "docker-compose.yml", "up", "-d") // Helper function to execute docker compose commands
cmd.Stdout = os.Stdout executeCommand := func(args ...string) error {
cmd.Stderr = os.Stderr var cmd *exec.Cmd
err = cmd.Run() if useNewStyle {
cmd = exec.Command("docker", append([]string{"compose"}, args...)...)
if err != nil { } else {
fmt.Println("Failed to start containers using docker-compose command") cmd = exec.Command("docker-compose", args...)
os.Exit(1) }
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
} }
return err // Pull containers
} fmt.Printf("Using %s command to pull containers...\n", getCommandString(useNewStyle))
if err := executeCommand("-f", "docker-compose.yml", "pull"); err != nil {
return fmt.Errorf("failed to pull containers: %v", err)
}
// Start containers
fmt.Printf("Using %s command to start containers...\n", getCommandString(useNewStyle))
if err := executeCommand("-f", "docker-compose.yml", "up", "-d"); err != nil {
return fmt.Errorf("failed to start containers: %v", err)
}
return nil
}

View file

@ -14,20 +14,16 @@ export default async function migration() {
try { try {
await db.transaction(async (trx) => { await db.transaction(async (trx) => {
await db.transaction(async (trx) => { trx.run(sql`UPDATE ${users} SET email = LOWER(email);`);
trx.run(sql`UPDATE ${users} SET email = LOWER(email);`); trx.run(
trx.run( sql`UPDATE ${emailVerificationCodes} SET email = LOWER(email);`
sql`UPDATE ${emailVerificationCodes} SET email = LOWER(email);` );
); trx.run(
trx.run( sql`UPDATE ${passwordResetTokens} SET email = LOWER(email);`
sql`UPDATE ${passwordResetTokens} SET email = LOWER(email);` );
); trx.run(sql`UPDATE ${userInvites} SET email = LOWER(email);`);
trx.run(sql`UPDATE ${userInvites} SET email = LOWER(email);`); trx.run(sql`UPDATE ${resourceWhitelist} SET email = LOWER(email);`);
trx.run( trx.run(sql`UPDATE ${resourceOtp} SET email = LOWER(email);`);
sql`UPDATE ${resourceWhitelist} SET email = LOWER(email);`
);
trx.run(sql`UPDATE ${resourceOtp} SET email = LOWER(email);`);
});
}); });
} catch (error) { } catch (error) {
console.log( console.log(