@earth-app/collegedb
    Preparing search index...

    Function validateTableForSharding

    • 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.

      Parameters

      • d1: D1Database

        The D1 database instance to check

      • tableName: string

        Name of the table to validate

      • primaryKeyColumn: string

        Expected primary key column name (defaults to 'id')

      Returns Promise<ValidationResult>

      Promise resolving to validation result with table info

      If table doesn't exist or validation fails

      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);
      }