Conversation
…xhigh: Please look at the repository. Carefully study all markdown files, and pay special attention to the architectural boundaries defined. This repository implements an ORM that currently only supports Postgres. I want you to identify all the areas we need to extend in order to also support SQLite. In addition to adding support, I want to also duplicate the demo app and port all the existing queries to SQLite. Please create a SQLITE-PLAN.md file that I can hand over to a coding agent to implement this. Point out all the work that has to be done, and be very explicit about the architectural boundaries we need to respect. Add a section called Architectural Challenges, and instruct the agent to list and explain any issues it has with the existing architectural decisions. It could be that we need to change some of the rules, but I want to have those changes clearly listed. After completing the plan document, start implementation.
| Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Note 🎁 Summarized by CodeRabbit FreeThe PR author is not assigned a seat. To perform a comprehensive line-by-line review, please assign a seat to the pull request author through the subscription management page by visiting https://app.coderabbit.ai/login. Comment |
| if (targetId === 'sqlite') { | ||
| return [ | ||
| { | ||
| sql: `create table if not exists prisma_contract_marker ( | ||
| id integer primary key, | ||
| core_hash text not null, | ||
| profile_hash text not null, | ||
| contract_json text, | ||
| canonical_version integer, | ||
| updated_at text not null default (CURRENT_TIMESTAMP), | ||
| app_tag text, | ||
| meta text not null default '{}' | ||
| )`, | ||
| params: [], | ||
| }, | ||
| ]; | ||
| } | ||
| | ||
| // Default: Postgres schema + table. | ||
| return [ | ||
| { sql: 'create schema if not exists prisma_contract', params: [] }, | ||
| { | ||
| sql: `create table if not exists prisma_contract.marker ( | ||
| id smallint primary key default 1, | ||
| core_hash text not null, | ||
| profile_hash text not null, | ||
| contract_json jsonb, | ||
| canonical_version int, | ||
| updated_at timestamptz not null default now(), | ||
| app_tag text, | ||
| meta jsonb not null default '{}' | ||
| )`, | ||
| params: [], | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
We need an abstraction for this - it can't be a switch statement on target ID. Perhaps we could delegate this to the control adapter?
| readonly postgres?: { | ||
| readonly nativeType: string; // e.g. 'integer', 'text', 'vector', 'timestamp with time zone' | ||
| }; | ||
| readonly sqlite?: { | ||
| readonly nativeType: string; // e.g. 'integer', 'text', 'real' | ||
| }; |
There was a problem hiding this comment.
No target-keyed dictionaries in the SQL domain
| type SqlStatement = { readonly sql: string; readonly params: readonly unknown[] }; | ||
| | ||
| type WriteMarkerInput = { | ||
| readonly coreHash: string; | ||
| readonly profileHash: string; | ||
| readonly contractJson?: unknown; | ||
| readonly canonicalVersion?: number | null; | ||
| readonly appTag?: string | null; | ||
| readonly meta?: Record<string, unknown>; | ||
| }; |
There was a problem hiding this comment.
The control plane has been suffering for lack of a DDL query interface - this is really highlighted now 🙈
| if (config.contract.target === 'postgres') { | ||
| return { | ||
| createAdapter: () => new PostgresAdapter(), | ||
| createDriver: () => new KyselyPrismaDriver(config), | ||
| createIntrospector: (db: Kysely<unknown>) => new PostgresIntrospector(db), | ||
| createQueryCompiler: () => new PostgresQueryCompiler(), | ||
| }; | ||
| } | ||
| if (config.contract.target === 'sqlite') { | ||
| return { | ||
| createAdapter: () => new SqliteAdapter(), | ||
| createDriver: () => new KyselyPrismaDriver(config), | ||
| createIntrospector: (db: Kysely<unknown>) => new SqliteIntrospector(db), | ||
| createQueryCompiler: () => new SqliteQueryCompiler(), | ||
| }; | ||
| } |
There was a problem hiding this comment.
OMG another switch statement on target ID 😭
Prompt: