package mast import ( "database/sql" "embed" "log" ) //go:embed migrations/0001.sql var migration0001 embed.FS func RunMigrations(db *sql.DB) error { // Load the cr-sqlite extension // _, err := db.Exec("SELECT load_extension('./crsqlite.so', 'sqlite3_crsqlite_init')") // if err != nil { // return fmt.Errorf("failed to load cr-sqlite extension: %w", err) // } // Read the embedded SQL file sqlData, err := migration0001.ReadFile("migrations/0001.sql") if err != nil { log.Fatalf("Failed to read embedded SQL file: %v", err) } sqlQuery := string(sqlData) // Create the todos table and initialize it as a CRDT _, err = db.Exec(sqlQuery) if err != nil { return err } return nil }