intial commit

This commit is contained in:
2026-05-25 11:45:56 +05:30
commit 6ab508560f
73 changed files with 23713 additions and 0 deletions

41
tmp/check_schema.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"fmt"
"nearle/db"
"github.com/joho/godotenv"
)
func main() {
_ = godotenv.Load()
db.Connect()
if db.DB == nil {
fmt.Println("❌ Failed to connect to DB")
return
}
tables := []string{"deliveries", "deliveryqueues", "deliverylogs"}
for _, table := range tables {
fmt.Printf("\n--- Schema for %s ---\n", table)
var results []struct {
ColumnName string `gorm:"column:column_name"`
DataType string `gorm:"column:data_type"`
IsNullable string `gorm:"column:is_nullable"`
ColumnDefault *string `gorm:"column:column_default"`
}
db.DB.Raw(`
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = ?
AND column_name LIKE '%id'
`, table).Scan(&results)
for _, r := range results {
def := "NULL"
if r.ColumnDefault != nil {
def = *r.ColumnDefault
}
fmt.Printf("Col: %-15s | Type: %-10s | Null: %-3s | Def: %s\n", r.ColumnName, r.DataType, r.IsNullable, def)
}
}
}