The D1 database instance to check
Name of the table to validate
Expected primary key column name (defaults to 'id')
Promise resolving to validation result with table info
const validation = await validateTableForSharding(env.DB_EXISTING, 'users');
if (validation.isValid) {
console.log(`Table ${validation.tableName} is ready for sharding`);
console.log(`Primary key: ${validation.primaryKeyColumn}`);
console.log(`Record count: ${validation.recordCount}`);
} else {
console.error('Table validation failed:', validation.issues);
}
Checks if a table exists and has a primary key column that can be used for sharding. Returns information about the table structure and primary key.