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

    Function ensureSchema

    • Creates schema across every configured shard, idempotently.

      Wraps createSchemaAcrossShards with the two guards consumers keep rebuilding: an in-process once flag and a KV-backed versionKey gate. Pass either a single schema string (statements separated by ;) or an array of statements.

      Parameters

      • schema: string | string[]

        Schema SQL string, or an array of statements

      • options: EnsureSchemaOptions = {}

        Idempotency guards (once, versionKey/version)

      Returns Promise<void>

      Promise that resolves when schema is ensured on all shards

      If CollegeDB is not initialized or a statement fails

      1.2.4

      await ensureSchema(
      [
      'CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT NOT NULL)',
      'CREATE INDEX IF NOT EXISTS idx_users_name ON users (name)'
      ],
      { versionKey: 'schema:version', version: '3' }
      );