Complete tasks 3.2-3.3: Data models and DynamoDB table schemas

- Defined all 8 data models (Page, Widget, Bookmark, Note, TagAssociation, Group, Share, Preferences)
- Implemented DynamoDB table creation for all tables with proper schemas
- Added GSIs for efficient querying (UserBookmarksIndex, UserNotesIndex, TagItemsIndex, UserSharesIndex)
- Comprehensive test coverage for all table schemas
- Updated init-db command to create all tables
This commit is contained in:
2026-02-18 22:55:06 -05:00
parent 7175ff14ba
commit 9f07b0c6f9
13 changed files with 1363 additions and 6 deletions

View File

@@ -22,12 +22,34 @@ func main() {
log.Fatalf("Failed to create DynamoDB client: %v", err)
}
log.Println("Creating Users table...")
if err := db.CreateUsersTable(ctx); err != nil {
log.Fatalf("Failed to create Users table: %v", err)
// Create all tables
tables := []struct {
name string
create func(context.Context) error
}{
{"Users", db.CreateUsersTable},
{"Pages", db.CreatePagesTable},
{"Widgets", db.CreateWidgetsTable},
{"Bookmarks", db.CreateBookmarksTable},
{"Notes", db.CreateNotesTable},
{"TagAssociations", db.CreateTagAssociationsTable},
{"Groups", db.CreateGroupsTable},
{"SharedItems", db.CreateSharedItemsTable},
{"Preferences", db.CreatePreferencesTable},
}
for _, table := range tables {
log.Printf("Creating %s table...", table.name)
if err := table.create(ctx); err != nil {
log.Fatalf("Failed to create %s table: %v", table.name, err)
}
log.Printf("✓ %s table created successfully", table.name)
}
log.Println("✓ Users table created successfully")
fmt.Println("\nDatabase initialization complete!")
fmt.Println("All tables created:")
for _, table := range tables {
fmt.Printf(" - %s\n", table.name)
}
os.Exit(0)
}