Configuration object containing all necessary bindings and settings
// Basic setup with multiple shards - auto-migration happens automatically
initialize({
kv: env.KV,
shards: {
'db-primary': env.DB_PRIMARY, // Existing DB with data
'db-secondary': env.DB_SECONDARY // Another existing DB
},
strategy: 'round-robin'
});
// Existing data is now automatically accessible via CollegeDB!
// Advanced setup with coordinator
initialize({
kv: env.KV,
coordinator: env.ShardCoordinator,
shards: {
'db-east': env.DB_EAST,
'db-west': env.DB_WEST,
'db-central': env.DB_CENTRAL
},
strategy: 'hash'
});
Sets up the global configuration for the CollegeDB system. This must be called before any other operations can be performed. The configuration includes KV storage, available D1 shards, optional coordinator, and allocation strategy.
NEW: Automatically detects and migrates existing databases without requiring additional setup. If shards contain existing data with primary keys, CollegeDB will automatically create the necessary mappings for seamless operation.