Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Remove data migration

Smaug673970050408ae11
diff --git a/backend/app/app.go b/backend/app/app.go
index d2ec8f8b..210df390 100644
--- a/backend/app/app.go
+++ b/backend/app/app.go
@@ -4,7 +4,6 @@ import (
"alexandrie/services"
"alexandrie/utils"
"database/sql"
- "fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/minio/minio-go/v7"
@@ -65,41 +64,5 @@ func InitApp(config Config) *App {
}
Migrate(&config)
- DB_DATA_MIGRATION(app.DB)
return &app
}
-
-// This function is used to migrate the database
-// It will be called when the application is started
-func DB_DATA_MIGRATION(db *sql.DB) {
- // Select all categories with "workspace_id" not empty
- rows, err := db.Query("SELECT id, parent_id FROM ressources WHERE parent_id IS NOT NULL")
- // Update "created_timestamp" from ressources: set created_timestamp = created_timestamp of the parent (from documents table)
- if err != nil {
- fmt.Println("❌ Error while selecting ressources:", err)
- return
- }
- defer rows.Close()
- for rows.Next() {
- var id, parentID int
- if err := rows.Scan(&id, &parentID); err != nil {
- fmt.Println("❌ Error while scanning rows:", err)
- continue
- }
- // Get the created_timestamp of the parent
- var createdTimestamp string
- err = db.QueryRow("SELECT created_timestamp FROM documents WHERE id = ?", parentID).Scan(&createdTimestamp)
- if err != nil {
- fmt.Println("❌ Error while getting created_timestamp of parent:", err)
- continue
- }
- // Update the created_timestamp of the child
- _, err = db.Exec("UPDATE ressources SET created_timestamp = ? WHERE id = ?", createdTimestamp, id)
- if err != nil {
- fmt.Println("❌ Error while updating created_timestamp of child:", err)
- continue
- }
- fmt.Printf("βœ… Updated created_timestamp of child %d with parent %d\n", id, parentID)
- }
- fmt.Println("βœ… Database migration completed successfully")
-}