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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user