Files
Kiro/cmd/server/init_tables.go

46 lines
1.0 KiB
Go

package main
import (
"context"
"fmt"
"log"
"os"
"custom-start-page/internal/storage"
)
// InitializeTables creates all required DynamoDB tables
func InitializeTables() error {
ctx := context.Background()
// Get DynamoDB endpoint from environment (for local development)
endpoint := os.Getenv("DYNAMODB_ENDPOINT")
if endpoint == "" {
endpoint = "http://localhost:8000" // Default for DynamoDB local
}
// Create DynamoDB client
db, err := storage.NewDynamoDBClient(ctx, endpoint)
if err != nil {
return fmt.Errorf("failed to create DynamoDB client: %w", err)
}
log.Println("Creating Users table...")
if err := db.CreateUsersTable(ctx); err != nil {
return fmt.Errorf("failed to create Users table: %w", err)
}
log.Println("Users table created successfully")
// TODO: Add other table creation calls here as they are implemented
// - Pages table
// - Widgets table
// - Bookmarks table
// - Notes table
// - TagAssociations table
// - Groups table
// - SharedItems table
// - Preferences table
return nil
}