officer_db with atelier_ prefixes, like every other plugin
the extraction kept atelier's own postgres database, because the brief said to when the tables already had rows. the owner reversed it, and the reason is not tidiness: a plugin that behaves differently from every other plugin is a plugin nobody can reason about. the separate database meant a second connection string to set before install, a second thing to back up, a second thing to get wrong on a new machine, and failure modes no other plugin shares — none of it bought anything except avoiding a migration. four tables now: atelier_collections, atelier_collection_items, atelier_providers, atelier_generations. index and check constraint names carry the prefix too — those are global in postgres and are the one thing that would otherwise collide with another plugin. db/schema.ts re-exports the definitions rather than duplicating them: they stay beside the code that queries them in sidecar/db/, and that file exists to be found by gen-plugin-schemas. ATELIER_POSTGRES_URL is gone. db.ts reads OFFICERDEV_POSTGRES_URL ?? POSTGRES_URL, which the platform already sets. the standalone service's rows are NOT here and nothing depends on them being here — the old service is still running against the old database, untouched, and migrating is a separate watched step after this is proven on alpha.
This commit is contained in:
@@ -32,8 +32,7 @@ export type GenerationOperation = (typeof GENERATION_OPERATIONS)[number];
|
||||
* unauthenticated as ordinary images, so they need to be a file a static route can hand to
|
||||
* `new Response(Bun.file(...))` — not a column something has to decode first.
|
||||
*/
|
||||
export const generations = pgTable(
|
||||
'generations',
|
||||
export const generations = pgTable('atelier_generations',
|
||||
{
|
||||
/**
|
||||
* Also the filename on disk. One id means one image, so a row can be turned into a served URL
|
||||
@@ -123,11 +122,11 @@ export const generations = pgTable(
|
||||
finishedAt: timestamp('finished_at', { withTimezone: true }),
|
||||
},
|
||||
(table) => [
|
||||
check('generations_status_check', sql`${table.status} in ('queued', 'running', 'succeeded', 'failed')`),
|
||||
check('generations_operation_check', sql`${table.operation} in ('generate', 'edit')`),
|
||||
check('atelier_generations_status_check', sql`${table.status} in ('queued', 'running', 'succeeded', 'failed')`),
|
||||
check('atelier_generations_operation_check', sql`${table.operation} in ('generate', 'edit')`),
|
||||
// The queue reads "what is still to do, oldest first" on every tick and after every restart.
|
||||
index('generations_status_created_idx').on(table.status, table.createdAt),
|
||||
index('atelier_generations_status_created_idx').on(table.status, table.createdAt),
|
||||
// Every poll of a job is this lookup.
|
||||
index('generations_request_idx').on(table.requestId, table.index),
|
||||
index('atelier_generations_request_idx').on(table.requestId, table.index),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user