Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.3 KB
Raw Blame
import {
  openCloudDatabase,
  openInMemoryCloudDatabase,
  type CloudDatabase,
  type OpenCloudDatabaseInput
} from '@orca-cloud/cloud-database'
import { connectorSchemaChanges } from './connector-schema-changes.js'
import { connectorSchemaStatements } from './connector-schema.js'
import { discordSchemaStatements } from './discord-schema.js'
import { slackSchemaStatements } from './slack-schema.js'

// Production has run these CREATE TABLEs, so editing one never reaches it. Change the schema by
// appending idempotent statements (ADD COLUMN IF NOT EXISTS, nullable or defaulted) to
// connector-schema-changes.ts; connector-schema-upgrade.test.ts boots the shipped baseline, then
// this list.
export const connectorBootStatements = () => [
  ...connectorSchemaStatements(),
  ...slackSchemaStatements(),
  ...discordSchemaStatements(),
  ...connectorSchemaChanges()
]

export async function openConnectorDatabase(
  input: Omit<OpenCloudDatabaseInput, 'service' | 'schemaStatements'>
): Promise<CloudDatabase> {
  return await openCloudDatabase({
    ...input,
    service: 'connector',
    schemaStatements: connectorBootStatements()
  })
}

export async function openInMemoryConnectorDatabase(): Promise<CloudDatabase> {
  return await openInMemoryCloudDatabase(connectorBootStatements())
}